Wednesday, April 6, 2011

C: Printing to a file, read command line

fopen man page.

Using the in the util that save the machine IPs.


fclose man page.

Need to remember to do this.


fflush

Used to clear the file stream.


Sample C code.

fprintf(fp. "string");


Reading from the command line:


#include <stdio.h>  main(int argc, char *argv[]) { int i;  for(i = 0; i < argc; i++) 	printf("arg %d: %s\n", i, argv[i]); return 0; }

Another example:





No comments: