Click here to Skip to main content
16,023,117 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if i want use this function ---> gets() <--- in visual studio, what library should i use? i used iostream & string , but it's not enough.
Posted
Comments
Aescleal 14-Apr-12 5:25am    
While both solutions are dead on the money, NEVER use gets, even in C. If you do you're opening yourself up to all sorts of strange and interesting errors. AND if you ever use it in a networked application you're asking for a denial of service attack.

Good alternatives are std::getline in C++ and fgets in C.

Cheers,

Ash

As stated by the documentation[^], you must include stdio.h, e.g.
C++
#include <stdio.h>

or (better)
C++
#include <cstdio>
 
Share this answer
 
v2
Comments
eli551 13-Apr-12 9:47am    
thank a lot
CPallini 13-Apr-12 16:46pm    
You are welcome.
Espen Harlinn 13-Apr-12 10:05am    
5'ed!
CPallini 13-Apr-12 16:47pm    
Thanks.
I think it's in
C++
#include <stdio.h>

Or, if you want to do it proper (it'll be inside namespace std if you do);
C++
#include <cstdio>


Hope this helps,
Fredrik
 
Share this answer
 
v2
Comments
eli551 13-Apr-12 9:41am    
thx. but that was false
Fredrik Bornander 13-Apr-12 9:50am    
How was that false?
Espen Harlinn 13-Apr-12 10:06am    
It should, have a 5 :-D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900