A
Adi
Hello friend,
Lately, i cam accross a small problem that has causing quite more
pain.
Scanf hangs whenever i try to re- take input into the same char array.
I've pasted below excerpt of my code:
----------------------------------------------------------------------------------------------------------------------------------------
short cond =0;
unsigned char intStr[CLI_MAX_INT16_CHARS];
/*loops until the value entered is valid*/
do
{
fflush(stdin);
scanf("%s",intStr);
cond=validateSInt(intStr);
}while(cond==1);
----------------------------------------------------------------------------------------------------------------------------------------
Given below is the stack trace of my code when i preempted it on SIGINT
(Ctrl+C). As u can see, the stack dump shows that scanf is hanged....
(gdb) where
#0 0x001e016e in __read_nocancel () from /lib/tls/libc.so.6
#1 0x0017cbb8 in _IO_file_read_internal () from /lib/tls/libc.so.6
#2 0x0017be8e in _IO_new_file_underflow () from /lib/tls/libc.so.6
#3 0x0017e5cd in _IO_default_uflow_internal () from /lib/tls/libc.so.6
#4 0x0017e27d in __uflow () from /lib/tls/libc.so.6
#5 0x00168cb4 in _IO_vfscanf_internal () from /lib/tls/libc.so.6
#6 0x0016e67a in scanf () from /lib/tls/libc.so.6
Lately, i cam accross a small problem that has causing quite more
pain.
Scanf hangs whenever i try to re- take input into the same char array.
I've pasted below excerpt of my code:
----------------------------------------------------------------------------------------------------------------------------------------
short cond =0;
unsigned char intStr[CLI_MAX_INT16_CHARS];
/*loops until the value entered is valid*/
do
{
fflush(stdin);
scanf("%s",intStr);
cond=validateSInt(intStr);
}while(cond==1);
----------------------------------------------------------------------------------------------------------------------------------------
Given below is the stack trace of my code when i preempted it on SIGINT
(Ctrl+C). As u can see, the stack dump shows that scanf is hanged....
(gdb) where
#0 0x001e016e in __read_nocancel () from /lib/tls/libc.so.6
#1 0x0017cbb8 in _IO_file_read_internal () from /lib/tls/libc.so.6
#2 0x0017be8e in _IO_new_file_underflow () from /lib/tls/libc.so.6
#3 0x0017e5cd in _IO_default_uflow_internal () from /lib/tls/libc.so.6
#4 0x0017e27d in __uflow () from /lib/tls/libc.so.6
#5 0x00168cb4 in _IO_vfscanf_internal () from /lib/tls/libc.so.6
#6 0x0016e67a in scanf () from /lib/tls/libc.so.6