ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I tried to include my own version of your fixed source, but everytime i previewed my post...the code's formatting was lost and yes, i did try to include it as code. So when I refer to a line number, count down your code - with the first include being line #1.
The first fix was on line #14, the smile was confusing the compiler. You see, on the first try you entered in \__/ which translates to the escape sequence \_ (which doesnt exist) followed by underscores and finally a / . This is not what you wanted. So in order to include a \ character into a string statement you need to use the escape sequence \\ which translates into a single \ .
That takes care of the smile, next we tackle the "syntax error before string constant" error. That error is on line # 17. You had this: cout << " "happy" " << endl; what you wanted was the word happy with quotes, with white space on both sides. But when the compiler sees this, it thinks happy is a variable since it is outside of the two sets of quotes! It thinks you meant this: cout <<" " << happy << " " << endl ; But you just goofed up and didnt put that other <<operator in! What you needed were two \" escape sequences before and after the happy to print two quotes and not end your string.
Never cared for the smiley face algorithm's i've seen, in book's nor in actual code, for me, despite the many book's, which, in fact, had little to do with smiley face's, never gave me a sense of tightness that i was looking for in smiley face code, oh we'll. :D
ive included a man standing because he looks so much better than the crap smiley face i did(need a bigger datatype something with maybe 144 bits) the only reason i used c++ was so i could declare bit inside the for loop.
you must have quite a pedantic compiler, on line 9 put ll after the hex number, ie
Code:
if((long long)1<<bit & 0x81006600423c0081ll)
if that doesnt work i suggest you try a different gcc, there have been errors reported in gcc 3.3. ive compiled it on gcc 3.2.1 and sun's C++ compiler(wont tell me version) no problem but on gcc 2.95.2 the ll was needed.
ive included a man standing because he looks so much better than the crap smiley face i did(need a bigger datatype something with maybe 144 bits) the only reason i used c++ was so i could declare bit inside the for loop.
Hi kev, that's quite complex, i like....but mabey something a little more 'C' shall we...
Code:
int main(int argc, argv*)
{
if (argv[0] == '--help')
printf("Please enter your mood, :( , :P , ;));
else if (argv[1] == ':(' || argv[1] == ':P' || argv[1] == ';)')
printf("\n\n\n:)\n\n\n");
else
printf("Bad Commandline Argument, please type '--help' for assistance");
return 0;
}
I didn't compile this code, so excuse any mistake's, but hopefully you get the genreal idea. :D
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.