#include<stdio.h> int main() { int x; printf(\"\ your coded message \ \"); FILE
ID: 3652298 • Letter: #
Question
#include<stdio.h>
int main()
{
int x;
printf(" your coded message ");
FILE *infile;
char buf[1000];
infile =fopen("Code.txt","r");
if (!infile)
return 1;
while (fgets(buf,1000, infile)!=NULL)
printf("%s",buf);
fclose(infile);
infile =fopen("message.txt", "w");
if (!infile)
return 1;
for (x=1; x<=10; x++)
fprintf(infile,"%d ", x);
fclose(infile);
return 0;
}
need help in creating 2 dimensional character array and alo printing the file
your program should reads in an input file named "Code.txt", reads words from that file (until EOF), and then "decodes" the message hidden in the input by saving every fifth word into a 2-dimensional character array (array of cstrings). As you read words from the file, print them to the screen as a paragraph (rather than one word per line, as found in the file).
here is my text file
One
perspective
is
that
Computer
information
is
not
really
Science
There
are
not
even
262
types
of
processors.
This
is
a
strange
comment
on
the
overall
views
of
the
greatest
leaders
the
world's
elite
class
has
ever
known.
Not
ever!
Explanation / Answer
#include #include int main() { int x; printf(" Coded Message: "); FILE *infile; char buf; infile =fopen("Code.txt","r"); if (!infile) return 1; char msg[100][100]; int i=0; int count=1; int j=0; while (fscanf(infile,"%c",&buf)!=EOF) { if(buf==' ') { printf(" "); if(count%5==0 && count!=0) { msg[i][j]=''; i++; j=0; } count++; } else { if(count%5==0) { msg[i][j++]=buf; } printf("%c",buf); } } printf(" Decoded Message: "); for(j=0;jRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.