Tuesday, July 14, 2009

Compile Errors for C++?

These are my compile errors


1. In function `int main()':





2. ambiguous overload for 'operator%26gt;%26gt;' in 'std::cin %26gt;%26gt; "%c"'





note: candidates are: std::basic_istream%26lt;char, _Traits%26gt;%26amp; std::operator%26gt;%26gt;(std::basic_istream%26lt;char, _Traits%26gt;%26amp;, unsigned char*) [with _Traits = std::char_traits%26lt;char%26gt;] %26lt;near match%26gt;





3. expected primary-expression before '%26gt;%26gt;' token





4. expected `;' before ')' token











#include %26lt;iostream%26gt;





#include %26lt;cstdlib%26gt;


#include %26lt;ctime%26gt;


using namespace std;











int random_1();











int main()











{





int i = 0;





int j = 0;





int check;





int check_1;





char play_again = '\n' ;











int tortoise[70];





int hare[70];











cout %26lt;%26lt; "BANG !!!!!" %26lt;%26lt; endl;





cout %26lt;%26lt; "AND THEY'RE OFF !!!!!" %26lt;%26lt; endl;

















while(play_again == '\n')





{











while(i %26lt;= 69 %26amp;%26amp; j %26lt;= 69)





{











tortoise[i] = 0;;





check = random_1();











if(check == 1 || check == 2 || check == 3 || check == 4 || check ==


5)





tortoise[i+=3] = 0;











if(check == 6 || check == 7)





tortoise[i-=6] = 0;











if(check == 8 || check == 9 || check == 10)





tortoise[i+=1] = 0;











char *ptr;





char line[71] = "---------------------------------------...











ptr = line;











if(i %26lt; 0){





i = 0;





*(ptr + i) = 'T';}











*(ptr + i) = 'T';











hare[j] = 0;





check_1 = random_1();











if(check_1 == 1 || check_1 == 2)





hare[j] = 0;











if(check_1 == 3 || check_1 == 4)





hare[j+=9] = 0;











if(check_1 == 5)





hare[j+=12] = 0;











if(check_1 == 6 || check_1 == 7 || check_1 == 8)





hare[j++] = 0;











if(check_1 == 9 || check_1 == 10)





hare[j-=2] = 0;











if(j %26lt; 0){





j = 0;





*(ptr + j) = 'H';}











*(ptr + j) = 'H';











if(i == j){





*(ptr + i) = 'O';





*(ptr + i + 1) = 'U';





*(ptr + i + 2) = 'C';





*(ptr + i + 3) = 'H';}











cout %26lt;%26lt; "%s\n\n" %26lt;%26lt; endl;











break;











}

















if(i %26gt;= 69)





{





cout %26lt;%26lt; "TORTOISE WINS!!! YAY!!!" %26lt;%26lt; endl;





break;





}











if(j %26gt;= 69)





{





cout %26lt;%26lt; "HARE WINS. YUCH." %26lt;%26lt; endl;





break;





}











if(j %26gt;= 69 %26amp;%26amp; i %26gt;= 69)





{





cout %26lt;%26lt; "IT'S A TIE" %26lt;%26lt; endl;





break;





}











cout %26lt;%26lt; "Press enter" %26lt;%26lt; endl;





cin %26gt;%26gt; "%c",%26gt;%26gt; %26amp;play_again); // Error Here











}











return 0;

















}





int random_1()











{





srand(time(NULL));





return (1 + rand() % 10);





}

Compile Errors for C++?
cout %26lt;%26lt; "%s\n\n" %26lt;%26lt; endl;





cin %26gt;%26gt; "%c",%26gt;%26gt; %26amp;play_again); // Error Here





You're trying to use "printf"-like formatting statements into cin and cout.





You can't do that. If you want to use printf, use printf. If you want to use cout, use cout. But don't try to do both.
Reply:http://www.gamedev.net/community/forums/...





http://www2.hawaii.edu/~pautler/How-to/c...





http://www.daniweb.com/forums/thread1332...





http://www.arachnoid.com/cpptutor/setup_...





http://developers.sun.com/solaris/articl...





http://www.codepedia.com/1/CppBuilder+co...





http://www.pic.ucla.edu/piclab/lang/c++/...





http://groups.google.com/group/comp.lang...








http://www.artima.com/cppsource/safelabe...





http://www.parasoft.com/jsp/products/hom...





http://developers.sun.com/sunstudio/docu...





http://digital.ni.com/public.nsf/allkb/9...
Reply:Basically, you have mixed up C language syntax with C++ language syntax over here; which is why it might be throwing up an error. Use either C++, or C.
Reply:class student


{


int


english,computr science;


float average;


char name{15};





public:


void


acceot_student_details();


void


display_student_detail();


}


No comments:

Post a Comment