Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<string.h>
- #include <time.h>
- struct FtpFile {
- const char *filename;
- FILE *stream;
- };
- char* pass_string();
- void CheckAndInsertLetter(char* word, char guess);
- int main(void)
- {
- char guess;
- char *c = pass_string();
- printf("%c", c);
- printf("Enter guess: ");
- scanf("%c", &guess);
- return 0;
- }
- void CheckAndInsertLetter(char* word, char guess) {
- }
- char* pass_string() //keep square brackets in signature
- {
- char availableWords[23206][8];
- FILE *fptr;
- int counter = 0;
- fptr = fopen("words.txt", "r+");
- char buffer[8];
- while (fgets(buffer, sizeof buffer, fptr) != NULL)
- {
- //printf("%s", buffer);
- if (buffer[0] != '\n') {
- availableWords[counter][0] = buffer[0];
- availableWords[counter][1] = buffer[1];
- availableWords[counter][2] = buffer[2];
- availableWords[counter][3] = buffer[3];
- availableWords[counter][4] = buffer[4];
- availableWords[counter][5] = buffer[5];
- availableWords[counter][6] = buffer[6];
- availableWords[counter][7] = buffer[7];
- // process buffer
- counter = counter + 1;
- }
- }
- if (feof(fptr))
- {
- printf("End of File\n");
- fclose(fptr); //fptr is the file pointer associated with file to be closed.
- }
- else
- {
- // some other error interrupted the read
- }
- srand((unsigned)time(NULL)); // should only be called once
- int r = rand();// % 23206;
- int value = (r % 23206) + 1;
- printf("%i", value);
- return availableWords[value][0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement