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
5 Answers
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
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
0
well c is simply a character i want the program to search it in the string
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/
0
thanks