Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Reads a file.
- //Takes the file path as an argument.
- void fileread(char f[]) {
- FILE *file = fopen(f, "r");
- int line = 0;
- int character = 0;
- if (file != NULL) {
- char c;
- while((c = fgetc(file)) != EOF) {
- File[line][character] = c;
- if (c == '\n') {
- line++;
- character = 0;
- }
- else {
- character++;
- }
- }
- fclose(file);
- }
- else {
- printf("Error: No such file.\nStarting without an input file.\n");
- }
- Lines = line++; //Update line count.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement