I have to write a C++ program to pass a command line argument into a shell script. My code will compile but when I try to run the program with the argument it starts a new line like it's waiting for input instead of passing the argument into the script.
This is my C++ code:
#include <iostream>
#include <cstdio>
#include <cstdlib>
char command[50];
int main(int argc, char *argv[])
{
sprintf(command, "%s %s", "./findName", argv[1]);
system(command);
}
I'm running the file from a unix terminal like this:
./findName someargument