Can any one define this (and its utility) for me, as concretely as possible? It is include in my code and only returns an error.
char * pch;
Can any one define this (and its utility) for me, as concretely as possible? It is include in my code and only returns an error.
char * pch;
"Nay! But you love the present life!"
Ok, (been typing all day...)sorry, more clearly now:
char * pch; = ???
"Nay! But you love the present life!"
What error are you getting?
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com
Its a pointer to a char. My advice: don't deal with pointers until you get to them in your study of C++.
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
full piece of code snippet:related error: "arguement of type "int" is incompatible with parameter of type "const char" *Code:char * pch; pch=strstr (str, 'good');
Code:#include <stdio.h> #include <fstream> #include <iostream> #include <string.h> #include <windows.h> using namespace std; int main() { char str[]="good"; char grabber[256]; cout<< "Hello, how are you today?\n"<< endl; cin.getline(grabber,256); char * pch; pch=strstr (str, 'good'); //Searching for “good” in ^ Char str if(pch !=NULL) cout<< "I am glad to hear you are doing well today."<< endl; else cout<< "Is anything wrong at all? Would you like to discuss it? \n"<< endl; Sleep(50000); return 0; //END }
"Nay! But you love the present life!"
Ah,
A simple error:Try changing the pair of single quotes ('') to double quotes ("").Code:pch=strstr(str, 'good');
The function strstr() takes a string [array of characters] for the second argument. By sending 'good', that can cause simple issues because the single quotes are to define a single character while the double quotes define an array of characters.
- Stack Overflow
Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.
Does strstr() return an integer? Sounds like it does. You do seem to be trying to cover alot of c++ material at once. Take Zach's suggestion.
[edit]
nevermind, seems Stack Overflow solved the problem. strstr() doesn't return an int. I didn't even catch that S.O., just looked at the error.
[/edit]
Environment: OS X, GCC / G++
Codes: Java, C#, C/C++
AOL IM: neandrake, Email: neandrake (at) gmail (dot) com