Created
July 22, 2015 03:31
-
-
Save d30jeff/d58e651f00ac84d67486 to your computer and use it in GitHub Desktop.
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
| #include <stdio.h> | |
| #include <string.h> | |
| char* getConfig(int lineNumber) | |
| { | |
| // const char fileName[150] = filePath; | |
| FILE *file; | |
| file = fopen("config.txt", "r"); | |
| int count = 0; | |
| if (file != NULL) | |
| { | |
| char singleLine[100]; | |
| while (fgets(singleLine, sizeof singleLine, file) != NULL) | |
| { | |
| if (count == lineNumber - 1) | |
| { | |
| return ("%s", singleLine); | |
| } | |
| else | |
| { | |
| count++; | |
| } | |
| } | |
| } | |
| fclose(file); | |
| } | |
| int main(void) | |
| { | |
| const char* myString = getConfig(4); | |
| printf("%s", myString); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment