473,396 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Scanf quary

is scanf not completely safe???
Aug 31 '07 #1
2 1356
dmjpro
2,476 2GB
is scanf not completely safe???
Welcome to TSDN.
In which sense you made this comment?

Kind regards,
Dmjpro.
Aug 31 '07 #2
JosAH
11,448 Expert 8TB
is scanf not completely safe???
Make that 'completely unsafe'. Imagine this:

Expand|Select|Wrap|Line Numbers
  1. char input[3]; // a small input buffer; it can hold two chars and a \0
  2. ...
  3. printf("enter two characters: "); flush(stdout);
  4. scanf("%s", input);
  5.  
my input:

thisisaverylongstringwithoutanyspacesinit.

get the picture?

kind regards,

Jos
Aug 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: B Thomas | last post by:
Hi, I was reading O'Reilly's "Practical C programming" book and it warns against the use of scanf, suggesting to avoid using it completely . Instead it recomends to use using fgets and sscanf....
14
by: Peter Mount | last post by:
Hello I'm having trouble with " scanf("%c", &answer);" on line 20 below. When I run the program in cygwin on Windows 98SE it skips that line completely and ends the program. Does scanf have...
7
by: hugo27 | last post by:
obrhy8 June 18, 2004 Most compilers define EOF as -1. I'm just putting my toes in the water with a student's model named Miracle C. The ..h documentation of this compiler does state that when...
14
by: main() | last post by:
I know this is the problem that most newbies get into. #include<stdio.h> int main(void) { char a; scanf("%c",&a); /*1st scanf */ printf("%c\n",a); scanf("%c",&a); /*2nd scanf*/...
4
by: mumbai10 | last post by:
oracle quary I want to transfer data from ms excel to oracle or how can i import data from ms excel to oracle
2
by: dreamer247 | last post by:
hii.. I have written a quary in sqlserver 2000 and the out put is not as expected... the quary is.. $sql="SELECT NAME,ROOM,DESIG,EMAIL,PHONE,START_DATE,END_DATE,CHAIRED_BY FROM CRB_MEETING...
4
by: ahmed222too | last post by:
when i use this quary to add new column, the engine reject the table name and focus on (-) in the table name alter table AH10-A1*1*1-101006 add column sss note: this schema of table name...
3
by: Tinku | last post by:
#include<stdio.h> main() { char line; scanf("%", line); printf("%s", line); } it will read and print the line but what is "%" in general we gives %s, %c .
2
by: subramanian100in | last post by:
Consider the following program named as x.c #include <stdlib.h> #include <stdio.h> int main(void) { unsigned int u; char str;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.