for example:
read(file.txt); //read it line by line
var1 = line1;
var2 = line2;
you read the data from a file then set it to any variable you have after reading it.
any help would be great. trying to figure it out myself as well. thank you.



FILE* file = fopen("filename", "r");
// this creates a FILE* variable called file
// the fopen opens a file filename, with certain permissions
// in this case "r" means read permission
// to write you can use "w" (beware opening a file like this overwrites the file
FILE* file_p = fopen("filename", "r");
fscanf(file_p, "%s", string1);
fscanf(file_p, "%s", string2);
fclose(file_p); // lastly is to use fclose to actually close the file
Users browsing this forum: No registered users and 1 guest