- #1
stellina
- 8
- 0
Hello! I am learning how to use file and argc and I am stuck on this assignment : write a program that sequentially displays on screen the contents of all of the files listed in the command line. Use argc to control a loop.
Here is my code, I'll try to enclose it in [ CODE ] [ /CODE ] tags if it doesn't work please explain how to do it:
[#include <stdio.h>
#include <stdlib.h>
int main (int argc, char * argv[])
{
int i;
FILE *fp;
for(i = 0; i < argc; i++)
fp = fopen(argv,"r");
fprintf(fp, "Testing...\n");
return 0;
}
]
I can't check if it works because I don't have any file in the command line and I know too little about files, the book doesn't help much. Thanks
Here is my code, I'll try to enclose it in [ CODE ] [ /CODE ] tags if it doesn't work please explain how to do it:
[#include <stdio.h>
#include <stdlib.h>
int main (int argc, char * argv[])
{
int i;
FILE *fp;
for(i = 0; i < argc; i++)
fp = fopen(argv,"r");
fprintf(fp, "Testing...\n");
return 0;
}
]
I can't check if it works because I don't have any file in the command line and I know too little about files, the book doesn't help much. Thanks