i have to read input from .sql file .but that file name should be read from command line instead of cin.how to do that command?
if my file t.sql ,how it would be?
i tried like this but i couldnt get the output
int main(int argc, char* argv[])
which file i need to execute?
g++ a.cpp
or g++ t.sql?
bernadlosini
0
Newbie Poster
Recommended Answers
Jump to PostTry something like this:
char filename[20]; if(argc>1) { filename = argv[1]; }
In your example you have to use strcpy()
strcpy(filename, argv[1]);
All 4 Replies
mvmalderen
2,072
Postaholic
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
mvmalderen
commented:
Everyone makes mistakes :)
+4
mvmalderen
2,072
Postaholic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.