Jul 9, 2014 at 12:22pm UTC
/*This is just simple but i cant locate the error! everytime i run this code the printf at last didnt appear! please help.*/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#include<stdio.h>
#include<conio.h>
main()
{
char fname[10],mname[10],lname[10];
clrscr();
gotoxy(7,1);textcolor(YELLOW);
cprintf("YOur first name? " );
textcolor(RED);
cscanf("%s" ,&fname);
gotoxy(7,2);textcolor(YELLOW);
cprintf("YOur first name? " );
textcolor(RED);
cscanf("%s" ,&mname);
gotoxy(7,3);textcolor(YELLOW);
cprintf("YOur first name? " );
textcolor(RED);
cscanf("%s" ,&lname);
gotoxy(7,5);textcolor(GREEN);
cprintf("Welcome %s %s. %s" ,fname,mname,lname);
getch();
}
Last edited on Jul 9, 2014 at 1:53pm UTC
Jul 9, 2014 at 12:46pm UTC
I'm not really familiar with microsoft-specific stuff, but I'm guessing you just need to add "\n" to the end of the string in the last cprintf-command.
Jul 9, 2014 at 12:53pm UTC
thanks for the reply sir, i will try it! thx
Jul 9, 2014 at 12:57pm UTC
sir! i try ur suggestion but! it doest work! what i gonna do! please help!
Jul 9, 2014 at 1:33pm UTC
According to this MSDN page, cprintf is deprecated and can not be used in the Windows runtime.
http://msdn.microsoft.com/en-us/library/ms235371.aspx
The above MSDN page recommends the use of the C++ conformant _cprintf or _cprintf_s functions. Note that these functions ignore the \n character.
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Last edited on Jul 9, 2014 at 1:33pm UTC
Jul 9, 2014 at 1:55pm UTC
thank u sir! but i didnt get it! im just a newbie? can u explain it easier? hmmm
Jul 9, 2014 at 2:17pm UTC
What part don't you get?
Deprecated means obsolete or not supported any more.
Did you read the Microsoft link?
Use _cprintf instead. That's pretty obvious.
Code tags? Read the link provided.
Last edited on Jul 9, 2014 at 2:19pm UTC