Search this site
Embedded Files
Skip to main content
Skip to navigation
SpaMioS
Home
Knowledge Base
Java
Files
Database
VBA
C
Apps
Premium budget
Baby, pregnant, and mum club
QR Shopping List
Family Cloud
PassBook
PassBook privacy policy
PrivacyPolicyKBTIM
Contact
cv
SpaMioS
Home
Knowledge Base
Java
Files
Database
VBA
C
Apps
Premium budget
Baby, pregnant, and mum club
QR Shopping List
Family Cloud
PassBook
PassBook privacy policy
PrivacyPolicyKBTIM
Contact
cv
More
Home
Knowledge Base
Java
Files
Database
VBA
C
Apps
Premium budget
Baby, pregnant, and mum club
QR Shopping List
Family Cloud
PassBook
PassBook privacy policy
PrivacyPolicyKBTIM
Contact
cv
Java
Useful
C
scripts
Read txt file char by char
char* filename = "data.txt";
FILE* file = fopen(filename, "r");
if (file == NULL)
{
printf("Error: could not open file %s", filename);
return 1;
}
char ch;
while ((ch = fgetc(file)) != EOF) {
printf("%c", ch);
}
fclose(file);
Read txt file
line by line
char* filename = "data.txt";
FILE* file = fopen(filename, "r");
if (file == NULL)
{
printf("Error: could not open file %s", filename);
return 1;
}
char line[256];
while (fgets(line, 256, file)) {
printf("%s", line);
}
fclose(file);
Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse