Jump to content
Alx Dubosky

scanf no c++

Recommended Posts

Alx Dubosky

boas pessoal ,queria saber como usar scanf no c++

tipo esse pequeno codigo pq estou programar c++ no visual studio 2013

int posx,posy;
scanf("%d %d",&posx,&posy);

Edited by Rui Carlos
GeSHi

Share this post


Link to post
Share on other sites
thoga31

Suponho que vens de C?

Em C++ pode-se usar scanf, mas regra geral usa-se o cin.

int posx, posy;
cin >> posx;
cin >> posy;

De qualquer das formas, esse scanf está correcto. Estás a obter algum erro?


Knowledge is free!

Share this post


Link to post
Share on other sites
thoga31

"Um erro". Ok. Vê onde está e porque ocorre, e tenta resolver. Se precisares de ajuda, apita.

Edited by thoga31

Knowledge is free!

Share this post


Link to post
Share on other sites
Alx Dubosky

esta a aparecer isso Error 1 "error C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS"

Share this post


Link to post
Share on other sites
thoga31

O Visual Studio está a avisar que scanf é deprecated e recomenda outros métodos, entre eles o scanf_s.


Knowledge is free!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.