I am a beginner in TurboC, my problem is putting a 'word' (string) inside the if/else statement, and then its output is on printf
here is my wrong code
#include <stdio.h>
main(){
int enter;
string thisword;
clrscr();
printf("Press number 1 then enter ");
scanf("%i",&enter);
if(enter==1){
thisword = 'Thanks';
}
else{
thisword = 'Error';
}
printf("\n%s",thisword);
getch();
return.0;
}
i dont want to put printf as a statements in every if/else brackets like
#include <stdio.h>
main(){
int enter;
clrscr();
printf("Press number 1 then enter ");
scanf("%i",&enter);
if(enter==1){
printf("\n Thanks");
}
else{
printf("\n Error");
}
getch();
return.0;
}
Aucun commentaire:
Enregistrer un commentaire