- Joined
- Dec 18, 2009
- Messages
- 2
- Reaction score
- 0
Hi, as the school year winds to a close, I find myself studying furiously for a class which has been...harder... then most for me. I have a real quick question, how do I take an argument from argv and make it a filename? For example, if my program is called "DistanceRan" and I want to record the distance George has run, my command line would read
./DistanceRan George
How would I make a program which creates Stan.txt? I've tried some things, but as you can tell, I am totally incompetent when it comes to programming, even after a semester of it.
Something I've tried is:
#include <stdio.h>
int main(int argc, char *argv)
{
if (argc>1)
{
char argv[]="%s";
char filesname[sizeof(argv+500);
sprintf(filesname, argv, argv[1]);
}
return 0;
}
but I get the error "no input files." Help please?
Thank you guys so much, from what I've read while lurking, you really know your stuff.
./DistanceRan George
How would I make a program which creates Stan.txt? I've tried some things, but as you can tell, I am totally incompetent when it comes to programming, even after a semester of it.
Something I've tried is:
#include <stdio.h>
int main(int argc, char *argv)
{
if (argc>1)
{
char argv[]="%s";
char filesname[sizeof(argv+500);
sprintf(filesname, argv, argv[1]);
}
return 0;
}
but I get the error "no input files." Help please?
Thank you guys so much, from what I've read while lurking, you really know your stuff.