Help--C++ very weak--I have to write and test code that recognizes one form of the comments of the C++ language (those that begin with /* and end with */). Thanks.
Help--C++ very weak--I have to write and test code that recognizes one form of the comments of the C++ language (those that begin with /* and end with */). Thanks.
Problem solved.Code:if(code.find("//*"){ cout<<"I can find comments"; }
Woop?
>Problem solved.
Better would be:
Code:if(code.find("/*"){ cout<<"I can find comments\n"; }
Sorry--here's more info-"C" version of it.
This was straight from the book--Thanks for helpingCode:int getComment() { getChar(); if (charClass != AST) return SLASH_CODE; else { do{ getChar(); while (charClass != AST) getChar(); } while (charClass != SLASH); return COMMENT; }
My bad so I can't type. Maybe I should make sure I can type better when I am being a jerk . And to be super technical neither of the answers work it needs to be:
Code:#include <iostream> #include <string> int main() { std::string code = "int main(){ /*Comment*/ int val = 10; return 0;} "; if(code.find("/*") != std::string::npos){ std::cout<<"I can find comments"; }//if //Wait for user input std::cin.get(); return 0; }
Last edited by prog-bman; 05-29-2007 at 04:09 PM.
Woop?
Thanks prog-bman