L35_MiscellanousTopics - CS1372 Miscellaneous Topics Idioms...

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CS1372 Miscellaneous Topics
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Idioms Just want to know if two strings are equal? if(strcmp(a, b) == 0) //They are equal or if(!strcmp(a, b)) // They are equal
Background image of page 2
Printing Out a Comma Separated List int things[] = {5, 3, 7, 5, 9, 2, 5) const char *prefix = ""; for (int i = 0; i < 7; i++) { printf("%s%d", prefix, things[i]); prefix = ", "; } Prints: 5, 3, 7, 5, 9, 2, 5
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Dealing with that pesky ‘s’ in English printf("It's %d apple%c\n", apple, (apple==1)? ' ':'s '); Predicate ? Value : value2
Background image of page 4
Control Flow There is a goto in C but it is not recommended for several reasons Optimization Performance Clarity Plus it will only jump inside a function
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Control Flow There is a construct that will allow jumping all over the place. USE IT SPARINGLY!!!!!
Background image of page 6
setjmp() … longjmp() #include <setjmp.h> jmp_buf x; // this will hold location x t = setjmp(x); // mark a location as x longjmp(x, 3); // transfer back to location x, and setjmp will have the return value 3 (an integer) Note: Read Wikipedia Article!!!!
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Return Value 0 means okay Anything else means a problem Main can return a value Any function can exit and set return value exit(99); You can see the value with: echo $?
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/07/2012 for the course CS 1372 taught by Professor Smith during the Spring '07 term at Georgia Institute of Technology.

Page1 / 28

L35_MiscellanousTopics - CS1372 Miscellaneous Topics Idioms...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online