Just wanted to know if anyone could help me with a reading from file problem.
When the program reads from a text file which is set out like this:
it only prints out the conversion of the last string, in this example case "b".
I'm guessing this is because of the while statement.
I just wanted to know if it possible to read in all the strings from a file and print out to another file, all the converted strings.
The only problem is that this was the given method by the teacher. I was told before that this way isnt the correct standard, but the problem is that was the structure we were asked to use.If you can help I would greatly appreciate it.
Here is my modified code, because this is a coursework assignment and I know a few people in my class use these boards.
printf("Please enter a file input path ");
fscanf(file_in, "%s", array1);
length = strlen(array1);
for ( counter = 0; counter < length; counter++ )
if ( romanchar[counter] == 'p' )
sum = sum + 3;
else if ( romanchar[counter] == 'b' )
sum = sum + 4;
else if ( romanchar[counter] == 'c' )
sum = sum + 5;
printf("Please enter a file output path ");
file_out = fopen(myfile, "w");
fprintf(file_out, "%d\n", sum);