0

What's the problem with this code?

hey guys this a c language code iam trying to run but it contains errors plz help me finding the problem. https://code.sololearn.com/cfm1gaBMHbYC/?ref=app

1st Jun 2018, 12:38 PM
veerendra singh
veerendra singh - avatar
5 odpowiedzi
0
Hi Veerendra, First of all, it's not very clear of what you are trying to achieve with this code. But here are some of the errors I noticed, 1. you cannot store a string into a pointer. so, line number 7 is incorrect. 2. in line 8, you are passing c but you have never assigned a value to it. Also on the same line you should be assinging the returned value from the function is_in
1st Jun 2018, 1:04 PM
heduson satchi
heduson satchi - avatar
0
well actually we can store a string in a pointer you should try it and thnx for replying, with this i want that when the while loop runs it searches the string for the character c
1st Jun 2018, 1:07 PM
veerendra singh
veerendra singh - avatar
0
well c is simply a character i want the program to search it in the string
1st Jun 2018, 1:09 PM
veerendra singh
veerendra singh - avatar
0
if you are trying to search the string i for character c, you should be passing it as 'c' ( within the single quotes) pointers only hold an address, they cannot hold all the characters in a character array. This means that when we use a char * to keep track of a string, the character array containing the string must already exist (having been either statically- or dynamically-allocated). Below is how you might use a character pointer to keep track of a string. char label[] = "Single"; char label2[10] = "Married"; char *labelPtr; labelPtr = label; source: http://www.cs.bu.edu/teaching/c/string/intro/
1st Jun 2018, 1:34 PM
heduson satchi
heduson satchi - avatar
0
thanks
1st Jun 2018, 2:10 PM
veerendra singh
veerendra singh - avatar