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:
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started