C++ Advance Input Problem |
Author :
mostafa
Post Date :
2006-03-17 13:16
Posts :
6
|
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. |
Author :
grant
Post Date :
2006-03-20 19:45
Posts :
117
|
Hi,
What exactly is your problem? Can you provide the line number where the error is occurring?
Regards,
Grant |
Author :
mostafa
Post Date :
2006-03-22 13:27
Posts :
6
|
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. |
Author :
grant
Post Date :
2006-03-22 19:16
Posts :
117
|
Hi,
Your source code post has expired. Can you please repost it?
Regards,
Grant |
Author :
mostafa
Post Date :
2006-03-23 15:14
Posts :
6
|
http://authors.aspalliance.com/aylar/ViewPasteCode.aspx?PasteCodeID=5464
this is my source code link. |
Author :
grant
Post Date :
2006-03-23 17:05
Posts :
117
|
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 |
Author :
mostafa
Post Date :
2006-03-24 08:38
Posts :
6
|
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. |
Author :
grant
Post Date :
2006-03-24 10:51
Posts :
117
|
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 |
Author :
mostafa
Post Date :
2006-03-24 14:58
Posts :
6
|
Thanks alot.
It really helped. |
All Rights Reserved, © Zeus Communications, Multimedia & Development 2004-2005