First draft
This commit is contained in:
commit
1cc8d385c6
3 files changed
+50
No files matched your search
@@ -0,0 +1,44 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
void loadWords(char words[]) {
|
||||
FILE *f = fopen("words", "r");
|
||||
|
||||
char buffer[100] = {0};
|
||||
int n = 0;
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), f) != NULL) {
|
||||
|
||||
|
||||
|
||||
for (int i = 0; i < strlen(buffer); i++) {
|
||||
if (buffer[i] == '\n')
|
||||
{
|
||||
buffer[i] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(&words[n][0], buffer);
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main() {
|
||||
char words[10][10] = {0};
|
||||
|
||||
loadWords(words);
|
||||
|
||||
printf("%s %s\n", words[0], words[2]);
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
Reference in new issue
Block a user