Created
July 21, 2015 03:56
-
-
Save d30jeff/792c897ab61985b8cfbf to your computer and use it in GitHub Desktop.
Read .txt file in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int read_config(char filePath, int lineNumber, char *lineValue) | |
| { | |
| const char fileName[150] = filePath; | |
| FILE *file; | |
| file = fopen(fileName, "r"); | |
| int count = 0; | |
| if (file != NULL) | |
| { | |
| char singleLine[200]; | |
| while (fgets(singleLine, sizeof singleLine, file) != NULL) | |
| { | |
| if (count == lineNumber) | |
| { | |
| printf(singleLine); | |
| } | |
| else | |
| { | |
| count++; | |
| } | |
| } | |
| } | |
| fclose(file); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment