I have a program that prompts a user for a string and then depending on the size of the string outputs varients of the inputted string with added or missing characters.
i.e.
int main() {
char cText[100];
cout << "Enter the Text: ";
cin >> cText; ( cText would be ABC )
// process cText to output
// sABCdef
I want to be able to setup the program to use strings passed as input parameters as well as prompting the user:
i.e.
int main(int argc,char* argv[]) {
int iStrCount = 0;
if(argc != 1) {
char cText[100];
cout << "Enter the Text: ";
cin >> cText; ( cText = ABC )
//Process cText
//output sABCdef
}
else
// process argv[]
// it outputs sABC**********def
// not actually the * char, but the a strange buffer character
}
What is happening is when I process argv[], I get the string as well as the buffer. Is there a way ( I'm sure there is ) to trim the "¡§d" within argv[] ?
(I have a feeling it's because I'm not defining an initial size to argv[].)
Is there a different way to do this?
Regards.
i.e.
int main() {
char cText[100];
cout << "Enter the Text: ";
cin >> cText; ( cText would be ABC )
// process cText to output
// sABCdef
I want to be able to setup the program to use strings passed as input parameters as well as prompting the user:
i.e.
int main(int argc,char* argv[]) {
int iStrCount = 0;
if(argc != 1) {
char cText[100];
cout << "Enter the Text: ";
cin >> cText; ( cText = ABC )
//Process cText
//output sABCdef
}
else
// process argv[]
// it outputs sABC**********def
// not actually the * char, but the a strange buffer character
}
What is happening is when I process argv[], I get the string as well as the buffer. Is there a way ( I'm sure there is ) to trim the "¡§d" within argv[] ?
(I have a feeling it's because I'm not defining an initial size to argv[].)
Is there a different way to do this?
Regards.