HI
I would like to open a file with text and numbers and copy from the text few words and numbers.
Like if you want some data from system and want to data from system location be stored into another location.
Example like if you want data of used memory(that is allready written in a file) to be stored in some other location, but in the file where numerical data is, there are also a few others numbers and I want just one to be copied to string.
I've managed to open file and know how to do to display all data in the file(EOF), but to pick only one number or word from text and display it in other program, that's a little bit too much for me. Can anyone help me?
Have a nice Day
Matt
I copied that from someone but here is only all file display
Code:
#include <stdio.h>
main()
{
char data[80]; /* Record read from the file. */
FILE *ptr; /* Pointer to the file. FILE is a
structure defined in <stdio.h> */
/* Open the file - no error checking done */
ptr = fopen("/proc/meminfo","r");
/* Read one record at a time, checking
for the End of File. EOF is defined
in <stdio.h> as -1 */
while (feof(ptr) == 0)
{
fgets(data, 80, ptr); /* Read next record */
if (data[0] == '#') continue; /* filter out the comments */
printf("%s",data); /* O/P the record to the screen */
}
fclose(ptr); /* Close the file. */
}