Question: Hey Guys can someone look over my code. My xcoder keeps saying my Build failed. its for c programming Here the assignment: IO Processing Assignment

Hey Guys can someone look over my code. My xcoder keeps saying my "Build failed". its for c programming

Here the assignment:

IO Processing Assignment

So in short, it has to allow the user to enter up to 1000 words and output them to a text file. Short and easy practice.

Text file output-binary file IO-Assignment

Outcome:

  • Student will demonstrate the ability to create and write to a text file.

  • Student will demonstrate the ability to create and write to a binary file.

  • Student will demonstrate the ability to open and read from a binary file.

Program Specifications:

You will create a menu driven program that allows the user to enter up to 1000 words. The menu will have options to add more words and to create a text document with all words. The program will have an option to allow the user to dump all words from the program. The program will automatically look for an existing binary file (assuming the code was run before) it found, the program will load all words from the binary file into the program. Each time the program ends, all words will be saved/loaded into the binary file.

YOU CANNOT

  • Use global variables, in this or any program ever.

  • Use goto statement(s) , in this or any program ever.

Here my code:

#include

#include

int superWord(char words[][100], char files){

FILE *filePoints;

filePoints = fopen("words.txt","r");

int j = 0;

if(filePoints == NULL){

printf("I'm sorry. Were unable to open the file.");

} else{

while (!frof(filePoints)) {

fscanf(filePoints, "%s", words[j]);

j++;

}

fclose(filePoints);

}

return --j;

}

void saveFile(char words[][100], int r, char files[]){

FILE *filePoints;

int j;

filePoints = fopen(files, "R");

if (filePoints == NULL) {

printf("I'm sorry. We unable to the file ");

return;

}

for (j = 0; j < r; j++) {

fprintf(filePoints, "%s ", words[j]);

}

printf("Success %d write into file ", r);

fclose(filePoints);

}

int main(){

int user, k = 0;

char words[1000][100], file[100];

printf(" Please enter you filename to load words: ");

scanf("%s", file);

k = superWord(words, file);

printf("Sucessful %d words loaded. ", k);

do{

printf(" --Menu-- ");

printf(" 1.Add a word ");

printf(" 2.Dump all words ");

printf(" 3.Exit Program ");

printf(" Please enter your choice here: ");

scanf("%d", &user);

switch (user) {

case 1:

printf(" Enter your word please: ");

scanf("%s", words[k]);

k++;

break;

case 2:

saveFile(words, k, file);

break;

case 3:

saveFile(words, k, file);

return 0;

break;

}

} while (user !=3);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!