Friday, July 31, 2009

HeLP WITH MY C++ PROGRAMMING?

This is what I have (the do...while loop won't run):





#include%26lt;conio.h%26gt;


#include%26lt;iostream.h%26gt;


#include%26lt;string.h%26gt;





void main()


{


char namelast[81], namefirst[81];


int count=0;





cout%26lt;%26lt;"Please enter your last name: "%26lt;%26lt;endl;


cin.get (namelast, 81);


cout%26lt;%26lt;"Please enter your first name: "%26lt;%26lt;endl;


cin.ignore(81, '\n');


cin.get (namefirst, 81);


cout%26lt;%26lt;"Based on the given information, your name is "%26lt;%26lt;namefirst%26lt;%26lt;" "%26lt;%26lt;namelast%26lt;%26lt;"."%26lt;%26lt;endl;





if(namelast=="Lee")


{


cout%26lt;%26lt;"You an AzN !"%26lt;%26lt;endl;


}


if(namelast=="Lee" %26amp;%26amp; namefirst=="Kyle")


{


do{ cout%26lt;%26lt;"YOU'RE A DOUCHE! "%26lt;%26lt;endl;


count=count++;


}while(getch());


cout%26lt;%26lt;"You just got owned "%26lt;%26lt;count%26lt;%26lt;" times, Kyle Lee! What now, DOUCHE?!"%26lt;%26lt;endl;


}


getch();


}

HeLP WITH MY C++ PROGRAMMING?
You need to do a string compare:





#include%26lt;conio.h%26gt;


#include%26lt;iostream.h%26gt;


#include%26lt;string.h%26gt;





int main()


{


char namelast[81], namefirst[81];


int count=0;





cout%26lt;%26lt;"Please enter your last name: "%26lt;%26lt;endl;


cin.get (namelast, 81);


cout%26lt;%26lt;"Please enter your first name: "%26lt;%26lt;endl;


cin.ignore(81, '\n');


cin.get (namefirst, 81);


cout%26lt;%26lt;"Based on the given information, your name is "%26lt;%26lt;namefirst%26lt;%26lt;" "%26lt;%26lt;namelast%26lt;%26lt;"."%26lt;%26lt;endl;





if(!strcmp(namelast,"Lee"))


{


cout%26lt;%26lt;"You an AzN !"%26lt;%26lt;endl;


}


if(!strcmp(namelast,"Lee") %26amp;%26amp; !strcmp(namefirst,"Kyle"))


{


do{ cout%26lt;%26lt;"YOU'RE A DOUCHE! "%26lt;%26lt;endl;


count=count++;


}while(getch());


cout%26lt;%26lt;"You just got owned "%26lt;%26lt;count%26lt;%26lt;" times, Kyle Lee! What now, DOUCHE?!"%26lt;%26lt;endl;


}


getch();


}





String compare will return 0 if the strings match.
Reply:I don't like this program...anyway, what is with the getch()? Also, count++ increments count, you don't have to assign count to it.





count++ is the same as saying count = count++

floral design

No comments:

Post a Comment