-
May 8th, 2010, 12:15 PM
#1
Problem with strchr
I'm trying to manage this code to work:
char * a = "b";
char * b = "abc";
strchr(a,b);
but it gives me the error:
error C2665: 'strchr' : none of the 2 overloads could convert all the argument types
What can cause this? and how can this be solved?
Thanks.
-
May 8th, 2010, 12:53 PM
#2
Re: Problem with strchr
Well, the cause is pretty obvious: the second parameter must be of the type int or unsigned int
You should better have described what you were trying to accomplish rather than complain on this error message.
Victor Nijegorodov
-
May 8th, 2010, 01:10 PM
#3
Re: Problem with strchr
well that doesn't make sense to me then.
I'm trying to find the first occurance of "b" in the string "abc", and if it is there then I need to know where exactly.
-
May 8th, 2010, 01:20 PM
#4
Re: Problem with strchr
Then why don't you want to write it according to your description:
Code:
strchr("abc", 'b');
Note that you are searching for a single character (therefore an apostrophe is expected), not for some string (in which case the quotation mark is used)
Victor Nijegorodov
-
May 8th, 2010, 01:22 PM
#5
Re: Problem with strchr
Thanks! Is there a function that looks for a string inside a string?
-
May 8th, 2010, 01:30 PM
#6
Re: Problem with strchr
If you couls use MFC - then CString::Find
Otherwise - have a look at STL std::string
Victor Nijegorodov
-
May 8th, 2010, 02:31 PM
#7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|