A scanf function lets you do ``formatted input'' analogous to printf 's formatted output. scanf reads from the standard input; a variant fscanf reads from a specified file pointer.

The sprintf and sscanf functions let you ``print'' and ``read'' to and from in-memory strings instead of files. We've seen that atoi lets you convert a numeric string into an integer; the inverse operation can be performed with sprintf : int i = 10; char str[10]; sprintf(str, %d, i);

We've used printf and fprintf to write formatted output, and getchar , getc , putchar , and putc to read and write characters. There are also functions gets , fgets , puts , and fputs for reading and writing lines (though we rarely need these, especially if we're using our own getline and maybe fgetline ), and also fread and fwrite for reading or writing arbitrary numbers of characters.

It's possible to ``un-read'' a character, that is, to push it back on an input stream, with ungetc . (This is useful if you accidentally read one character too far, and would prefer that some other part of your program read that character instead.)

You can use the ftell , fseek , and rewind functions to jump around in files, performing random access (as opposed to sequential) I/O.

The feof and ferror functions will tell you whether you got EOF due to an actual end-of-file condition or due to a read error of some sort. You can clear errors and end-of-file conditions with clearerr .

You can open files in ``binary'' mode, or for simultaneous reading and writing. (These options involve extra characters appended to fopen 's mode string: b for binary, + for read/write.)

There are several more string functions in <string.h . A second set of string functions strncpy , strncat , and strncmp all accept a third argument telling them to stop after n characters if they haven't found the \0 marking the end of the string. A third set of `` mem '' functions, including memcpy and memcmp , operate on blocks of memory which aren't necessarily strings and where \0 is not treated as a terminator. The strchr and strrchr functions find characters in strings. There is a motley collection of ``span'' and ``scan'' functions, strspn , strcspn , and strpbrk , for searching out or skipping over sequences of characters all drawn from a specified set of characters. The strtok function aids in breaking up a string into words or ``tokens,'' much like our own getwords function.

The header file <ctype.h contains several functions which let you classify and manipulate characters: check for letters or digits, convert between upper- and lower-case, etc.

A host of mathematical functions are defined in the header file <math.h . (As we've mentioned, besides including <math.h , you may on some Unix systems have to ask for a special library containing the math functions while compiling/linking.)

There's a random-number generator, rand , and a way to ``seed'' it, srand . rand returns integers from 0 up to RAND_MAX (where RAND_MAX is a constant define d in <stdlib.h ). One way of getting random integers from 1 to n is to call (int)(rand() / (RAND_MAX + 1.0) * n) + 1

Bhopal news
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

India website designer web development India php ecommerce developer | Web design India, Ecommerce web design | India web hosting website host india | Windows hosting India web hosting | Software development India | Flash web designer india