Hello, I am trying to write a code to copy a file which I can do as you can see below.
My question is do I insert numbers. Let me do an example
I can copy the file fine, but really have no clue how to insert numbers in the first of each line. If anyone could give me a clue or example that would be great. Thanks in advance.
Code:
void copy ()
{
// Local Definitions
int c;
int closeStatus;
FILE* spProverbs ;
FILE* spProverbsCopy;
// Statements
printf("Begin file copy\n");
if (!(spProverbs = fopen ("Proverbs.TXT", "r")))
{
printf("Error opening Proverbs.TXT for reading");
exit (101);
} // if open input
if (!(spProverbsCopy = fopen ("ProverbsCopy.TXT", "w")))
{
printf("Error opening ProverbsCopy for writing");
exit(201);
} // if open output
while ((c = fgetc(spProverbs)) != EOF)
fputc(c, spProverbsCopy);
fclose(spProverbs);
closeStatus = fclose(spProverbsCopy);
if (closeStatus == EOF)
{
printf("File close error.\a\n");
exit(200);
} // if close error
printf("File successfully created\n");
return;
}// copy
Code:
PROVERBS.TXT Between the devil and the deep sea: To choose between two equally bad alternatives in a serious dilemma. Where there's a will there's a way: When a person really wants to do something, he will find a way of doing it. A friend in need is a friend indeed: A friend who helps when one is in trouble is a real friend. Discretion is the better part of valor: If you say discretion is the better part of valor, you mean that avoiding a dangerous or unpleasant situation is sometimes the most sensible thing to do. Great talkers are little doers: Those people who talk a lot and are always teaching others usually do not do much work. Text after processing: 1. Between the devil and the deep sea: To choose between 2. two equally bad alternatives in a serious dilemma. 3. 4. Where there's a will there's a way: When a person 5. really wants to do something, he will find a way of 6. doing it. 7. 8. A friend in need is a friend indeed: A friend 9. who helps when one is in trouble is a real friend. 10. 11. Discretion is the better part of valor: If you say 12. discretion is the better part of valor, you mean 13. that avoiding a dangerous or unpleasant situation 14. is sometimes the most sensible thing to do. 15. 16. Great talkers are little doers: Those people who 17. talk a lot and are always teaching others usually 18. do not do much work.
Comment