How is "fscanf()" used in C++?
| Type | Description | Argument |
| c | Used to read a single character, if the width is more than 1 the function reads all the specified width of characters and stores them in successive locations of the array passed as argument. | char * |
| d | Represents a decimal integer that mey be preceeded with +/ - sign. | int * |
| e,E,f,g,G | Used to represent a floating point number containing a decimal point that may have a +/- sign with a e or E character. | float * |
| o | Specifies an octal value | int * |
| s | This format type is used to read string of characters until a whitespace is found. | char * |
| u | Unsigned decimal integer | unsigned int * |
| x,X | Represents a hexadecimal integer. | int * |
| #include <stdio.h> int main() { FILE *fp; char name[100]; fp = fopen("fscanfeg.txt", "r"); fscanf(fp, "%s", name); printf("%s\n", name); fclose(fp); return 0; } |