Question: Code Blocks C programming only. 1) Write a program that will create a file with a list all integers from 0 to 100 that are
Code Blocks C programming only.
1) Write a program that will create a file with a list all integers from 0 to 100 that are divisible by 3. Each number must be put on a separate line. For the assignment, you only need to submit the source code, not the resulting text.
2) Modify the copyfile.c program we went over in class (available on D2L) so that the program will copy the text from one file to another, but capitalize the first letter of each word in the new copy. In addition to the source code, create a small text file to test the program and copy and paste both the original and new text in the assignment.
#include
int main(void) { FILE *fp_in; //file pointer for source FILE *fp_out; //file pointer for target
char source[20]; //source file name char target[20]; //target file name char c = 1;
printf("Enter source file: "); scanf("%s", source); printf("Enter target file: "); scanf("%s", target);
fp_in = fopen(source, "r"); //open source file, read mode fp_out = fopen(target, "w"); //open (create) target file, write mode
//transfer one character at a time until EOF is reached while( ( c = fgetc(fp_in) ) != EOF ) //read character { fputc(c, fp_out); //write character }
fclose(fp_in); //close source file fclose(fp_out); //close target file
printf("Finished ");
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
