| | |
what doesnt work? plz help guys
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2006
Posts: 2
Reputation:
Solved Threads: 0
i have this program but it doenst work could you help me plz.
you just enter in sentence like: I like the cat. or The cat sees the rat. The cat likes me. then it will say the string is correct. but if you enter in I sees the cat. The cat like me. then it will say that the string is wrong. plz help me. ty
I'm using c++ 2005
you just enter in sentence like: I like the cat. or The cat sees the rat. The cat likes me. then it will say the string is correct. but if you enter in I sees the cat. The cat like me. then it will say that the string is wrong. plz help me. ty
I'm using c++ 2005
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; #include <string.h> #include <string> #include <queue> typedef queue<char*> CHARQUEUE; const int MyArray = 100; void InputFunction(char []); void lex(char *); void syntax(); CHARQUEUE Subject; CHARQUEUE Verb; CHARQUEUE Object; void main() { char UserInput[MyArray]; cout <<"Enter the sentence"<<endl <<"(E) to exit" << endl; cin.getline(UserInput, MyArray); InputFunction(UserInput); syntax(); if (!Subject.empty()) { cout << Verb.front() << endl; Verb.pop(); } main(); } void InputFunction(char mySentence[]) { char *tokenPtr, *nullPtr = NULL; tokenPtr = strtok(mySentence, " "); while (tokenPtr != NULL) { lex(tokenPtr); tokenPtr = strtok(nullPtr, " "); } } void lex(char *str) { if ((strcmp(str, "A") ==0) || (strcmp(str, "The")==0)) { Subject.push(str); } else if ((strcmp(str,"cat") == 0) || (strcmp(str,"rat")== 0) || (strcmp(str,"mat")== 0)) { cout <<strcmp(str,"cat") << endl; Subject.push(str); } else if (strcmp(str, "I")==0) { Subject.push(str); Subject.push("firstperson"); } else if (strcmp(str,"like")==0 || strcmp(str, "am")==0 || strcmp(str,"see")==0) { Verb.push(str); Verb.push("firstperson"); } else if (strcmp(str,"likes")==0 || strcmp(str,"is")==0 || strcmp(str, "sees")==0) { Verb.push(str); Verb.push("thirdperson"); } else if (strcmp(str,"a")==0 || strcmp(str, "the")==0) { Object.push(str); } else if (strcmp(str,"cat")==0 || strcmp(str,"rat")==0 || strcmp(str,"mat")==0) { if (strcmp(Object.back(), "a")==0 || strcmp(Object.back(), "the")==0) { Object.push(str); } } else if (strcmp(str, "me")==0) { Object.push(str); } else { cout << "String is not accepted." <<endl; exit(0); } } void syntax() { if (!Subject.empty() && !Verb.empty()) if(strcmp(Verb.back(),Subject.back())==0) { cout <<"String is correct" <<endl; } else cout <<"String is not accepted." <<endl; }
Last edited by dummies2; Oct 30th, 2006 at 11:56 pm.
![]() |
Similar Threads
- Internet explorer pop up blocker doesnt work (Web Browsers)
- python mysql doesnt work?plz help (Python)
- My Cd DRive doesnt work PLZ HELP (Storage)
- first website doesnt work well? (HTML and CSS)
- Creative webcam doesnt work!!! HELP!!!!! (USB Devices and other Peripherals)
- My phpbb forum doesnt work ? (PHP)
Other Threads in the C++ Forum
- Previous Thread: Please help me figure out whats wrong with my code
- Next Thread: Calculate total charges
| Thread Tools | Search this Thread |
api array beginner bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive return rpg sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






