C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28629
Number of posts: 94611

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
scanf_s is not doing anything when I use Visual Studio 2012 Posted by abroshan on 30 Oct 2012 at 11:48 AM
Hi ,, Need your help on this ..I am new to the C programing and wants to learn it and I am doing it on my own ..

#include "stdafx.h"
#include<stdio.h>


int main()

{
int x;
printf("Enter any number\n");
scanf_s("%d\n", &x);

printf("your number is %d\n", x);


return 0;
}


This gets compiled without any error but when I executes it .,.

printf works file asking Enter the number
and when I enter suppose 8 .. then I don't get anything , simply blank and cursor keeps jumping on next tile with hot enter ..

Can anyone help ? I know this will be silly .. but I am stuck

thanks
Report
Re: scanf_s is not doing anything when I use Visual Studio 2012 Posted by abroshan on 1 Nov 2012 at 3:40 PM
finally I got it

I should not be using \n in scanf statement



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.