Skip to content

Instantly share code, notes, and snippets.

@bkamapantula
Created October 24, 2011 00:49
Show Gist options
  • Save bkamapantula/1308141 to your computer and use it in GitHub Desktop.
Save bkamapantula/1308141 to your computer and use it in GitHub Desktop.
Reading files in C - Day 3
#include <stdio.h>
//Stores line
char row[4];
void main()
{
// File variable to open file
FILE *file_pointer = fopen("2columns.txt", "r");
// Reads file line by line
while(fgets(row, sizeof(row), file_pointer) != NULL)
{
printf("%s", row);
}
fclose(file_pointer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment