I wanna know about function that can be taken a string as one other than "argv".That means I didnt wanna read string char by char.i need to take whole string in one.
string problem
Collapse
X
-
Do you mean you want to pass a string as a argument to a c/c++ function and name it different from argv or do you mean pass a string to main?Originally posted by 19831030I wanna know about function that can be taken a string as one other than "argv".That means I didnt wanna read string char by char.i need to take whole string in one.
Passing a string to a function is no different from passing an array to a function. You can pass char[] to the function. -
By using char array I cant take string as one.I use C lang & char array read word one by one.I wanna use strcmp method without usung argv & directly entering word.I use any other type.Originally posted by devikacsDo you mean you want to pass a string as a argument to a c/c++ function and name it different from argv or do you mean pass a string to main?
Passing a string to a function is no different from passing an array to a function. You can pass char[] to the function.Comment
-
String data type is a character array. Do you mean input a string as a word rather than character by character?Originally posted by 19831030By using char array I cant take string as one.I use C lang & char array read word one by one.I wanna use strcmp method without usung argv & directly entering word.I use any other type.
use scanf("%s",str) ;
If not pls try to specify what you are tyring to achieveComment
-
To be more specific, you can useOriginally posted by 19831030By using char array I cant take string as one.I use C lang & char array read word one by one.I wanna use strcmp method without usung argv & directly entering word.I use any other type.
This will read your whole string instead of character by character :)Code:char * str; scanf("%s",str);
RegardsComment
Comment