Menu
Forums
Login | Register

Home > Forums > Problems / Complaints > C++ Advance Input Problem Page :  1 
C++ Advance Input Problem
Hello,
I'm a new user of your site.
I downloaded all the tutorial about C++/Win32/OpenGL/GLUT and i started reading and implementing them with my little knowledge of programming.
I created a program which consist of many function.Each function is the corresponding tutorial code with my modification.I also add a Text-based user interface to it but it interferes with the function of advanced input tutorial.
I don't know what to do.
Please help me.
I should mention that I use Visual Studio 2005(Pro).
http://authors.aspalliance.com/aylar/ViewPasteCode.aspx?PasteCodeID=5441
>>>This is the link to my source code.
Hi,

What exactly is your problem? Can you provide the line number where the error is occurring?

Regards,
Grant
As you see if you compile the program,the number 8 program wont work if it's being executed through that simple interface(number (8)) but if you comment that simple interfaces and uncomment the advanced_input(); function ,you will see that it works fine.
I don't know why this happens.

Thanks.
Hi,

Your source code post has expired. Can you please repost it?

Regards,
Grant
http://authors.aspalliance.com/aylar/ViewPasteCode.aspx?PasteCodeID=5464
this is my source code link.
Hi,

Visual Studio 2005 introduces new secure functions. Instead of calling a function such as scanf, one should rather use the scanf_s secure equivalent.

You can also simply place the following at the top of your source file :

#define _CRT_SECURE_NO_DEPRECATE

which will just tell the compiler not to insist that secure functions be used.

Please let me know if this helps.

Regards,
Grant
Thanks for that scanf problem.
But my main problem is this code:
void advanced_input()
{
char names[100];
cout << "Type name(s) with space between each name." << endl;
cout << "Name(s):";
cin.getline(names, 100);
cout << "Thank you " << names << endl;
system("pause");
}
if you compile this code alone(without using it in that switch/case statement,it works fine but if you use it through that code it doesn't work.It return and does not wait for input.
This is my main problem.

Thanks,
Mostafa Moradian.
Hi,

Oh right, I see the problem you are having.

Try adding the following to the beginning of the advanced_input function :

cin.seekg(0,ios::beg);
cin.clear();

This will move to the beginning of the input stream and clear the buffer so that C++ doesn't think that you have already entered data.

Please let me know if this helps.

Regards,
Grant
Thanks alot.
It really helped.

Home > Forums > Problems / Complaints > C++ Advance Input Problem Page :  1 

You need to be logged in to reply to this topic.


All Rights Reserved, © Zeus Communications, Multimedia & Development 2004-2005

Read the Disclaimer

Links