Strange Problem 
Author Message
 Strange Problem

Please reply to the newsgroup.

I am attempting to use the function _itoa without much luck, the statement
that is giving me trouble is:

                     _itoa(current_message_on, cat_line, 10);

Here's the information I got from the core, it claims the program bombed out
with a seg fault on the above line.

(gdb) bt
#0  0x2aaf5634 in ?? ()
#1  0x401044 in main () at delete.c:87
(gdb) fr 1
#1  0x401044 in main () at delete.c:87
87                      _itoa(current_message_on, cat_line, 10);
(gdb) p current_message_on
$4 = 1
(gdb) p cat_line
$5 = '\000' <repeats 99 times>
(gdb)

Any suggestions?

Thanks

Phil



Tue, 11 Dec 2001 03:00:00 GMT  
 Strange Problem


Quote:
> Please reply to the newsgroup.

> I am attempting to use the function _itoa without much luck, the
statement
> that is giving me trouble is:

>                      _itoa(current_message_on, cat_line, 10);

> Here's the information I got from the core, it claims the program bombed
out
> with a seg fault on the above line.

> (gdb) bt
> #0  0x2aaf5634 in ?? ()
> #1  0x401044 in main () at delete.c:87
> (gdb) fr 1
> #1  0x401044 in main () at delete.c:87
> 87                      _itoa(current_message_on, cat_line, 10);
> (gdb) p current_message_on
> $4 = 1
> (gdb) p cat_line
> $5 = '\000' <repeats 99 times>
> (gdb)

> Any suggestions?

Yes :-) Use sprintf instead.

sprintf(cat_line, "%d", current_message_on);

You'll want to check that I got those args the right way round. _itoa is
not an ANSI C function; I haven't used it for ages and might have
misunderstood which is your string and which is your int.

But I think you get the general idea.

If you still get the seg fault, check whether your char * actually has some
(enough) storage allocated to it.

--
Richard Heathfield

The bug stops here.



Tue, 11 Dec 2001 03:00:00 GMT  
 Strange Problem
Read the gdb info.  you can see plainly that current_message_on is an int,
and cat_line is a 100 char string.  Thats why I included the print of those
two variables.  Of course, if you use windows, you shouldn't even bother
trying.

Phil

Quote:

>Simple. Don't use _itoa(). It's not portable.

>Instead, use:

>char array[128];
>int x = 333;

>sprintf(array,"%d",x);

><< Any suggestions >>

>Without any idea how you have defined your variables? No, not really.
>--

>Paul Lutus
>www.arachnoid.com


>>Please reply to the newsgroup.

>>I am attempting to use the function _itoa without much luck, the statement
>>that is giving me trouble is:

>>                     _itoa(current_message_on, cat_line, 10);

>>Here's the information I got from the core, it claims the program bombed
>out
>>with a seg fault on the above line.

>>(gdb) bt
>>#0  0x2aaf5634 in ?? ()
>>#1  0x401044 in main () at delete.c:87
>>(gdb) fr 1
>>#1  0x401044 in main () at delete.c:87
>>87                      _itoa(current_message_on, cat_line, 10);
>>(gdb) p current_message_on
>>$4 = 1
>>(gdb) p cat_line
>>$5 = '\000' <repeats 99 times>
>>(gdb)

>>Any suggestions?

>>Thanks

>>Phil



Tue, 11 Dec 2001 03:00:00 GMT  
 Strange Problem
Simple. Don't use _itoa(). It's not portable.

Instead, use:

char array[128];
int x = 333;

sprintf(array,"%d",x);

<< Any suggestions >>

Without any idea how you have defined your variables? No, not really.
--

Paul Lutus
www.arachnoid.com

Quote:

>Please reply to the newsgroup.

>I am attempting to use the function _itoa without much luck, the statement
>that is giving me trouble is:

>                     _itoa(current_message_on, cat_line, 10);

>Here's the information I got from the core, it claims the program bombed
out
>with a seg fault on the above line.

>(gdb) bt
>#0  0x2aaf5634 in ?? ()
>#1  0x401044 in main () at delete.c:87
>(gdb) fr 1
>#1  0x401044 in main () at delete.c:87
>87                      _itoa(current_message_on, cat_line, 10);
>(gdb) p current_message_on
>$4 = 1
>(gdb) p cat_line
>$5 = '\000' <repeats 99 times>
>(gdb)

>Any suggestions?

>Thanks

>Phil



Tue, 11 Dec 2001 03:00:00 GMT  
 Strange Problem
Thanks a ton!!!

Phil


Quote:


>> Please reply to the newsgroup.

>> I am attempting to use the function _itoa without much luck, the
>statement
>> that is giving me trouble is:

>>                      _itoa(current_message_on, cat_line, 10);

>> Here's the information I got from the core, it claims the program bombed
>out
>> with a seg fault on the above line.

>> (gdb) bt
>> #0  0x2aaf5634 in ?? ()
>> #1  0x401044 in main () at delete.c:87
>> (gdb) fr 1
>> #1  0x401044 in main () at delete.c:87
>> 87                      _itoa(current_message_on, cat_line, 10);
>> (gdb) p current_message_on
>> $4 = 1
>> (gdb) p cat_line
>> $5 = '\000' <repeats 99 times>
>> (gdb)

>> Any suggestions?

>Yes :-) Use sprintf instead.

>sprintf(cat_line, "%d", current_message_on);

>You'll want to check that I got those args the right way round. _itoa is
>not an ANSI C function; I haven't used it for ages and might have
>misunderstood which is your string and which is your int.

>But I think you get the general idea.

>If you still get the seg fault, check whether your char * actually has some
>(enough) storage allocated to it.

>--
>Richard Heathfield

>The bug stops here.



Tue, 11 Dec 2001 03:00:00 GMT  
 Strange Problem

Quote:

>Please reply to the newsgroup.

>I am attempting to use the function _itoa without much luck, the statement
>that is giving me trouble is:

>                     _itoa(current_message_on, cat_line, 10);

>Here's the information I got from the core, it claims the program bombed
out
>with a seg fault on the above line.

>(gdb) bt
>#0  0x2aaf5634 in ?? ()
>#1  0x401044 in main () at delete.c:87
>(gdb) fr 1
>#1  0x401044 in main () at delete.c:87
>87                      _itoa(current_message_on, cat_line, 10);
>(gdb) p current_message_on
>$4 = 1
>(gdb) p cat_line
>$5 = '\000' <repeats 99 times>
>(gdb)

>Any suggestions?

What immediately comes to mind is trying a ms news group. There is no
_itoa() in standard C. I do know of a Microsoft extension by that name. If
that is what your using you might try asking your question at
microsoft.public.vc.language
Regards,
Greg Martin

- Show quoted text -

Quote:

>Thanks

>Phil



Tue, 11 Dec 2001 03:00:00 GMT  
 Strange Problem
No, this is under unix, but I already got an answer from Richard :)  Thanks
anyway

Phil


Quote:


>>Please reply to the newsgroup.

>>I am attempting to use the function _itoa without much luck, the statement
>>that is giving me trouble is:

>>                     _itoa(current_message_on, cat_line, 10);

>>Here's the information I got from the core, it claims the program bombed
>out
>>with a seg fault on the above line.

>>(gdb) bt
>>#0  0x2aaf5634 in ?? ()
>>#1  0x401044 in main () at delete.c:87
>>(gdb) fr 1
>>#1  0x401044 in main () at delete.c:87
>>87                      _itoa(current_message_on, cat_line, 10);
>>(gdb) p current_message_on
>>$4 = 1
>>(gdb) p cat_line
>>$5 = '\000' <repeats 99 times>
>>(gdb)

>>Any suggestions?

>What immediately comes to mind is trying a ms news group. There is no
>_itoa() in standard C. I do know of a Microsoft extension by that name. If
>that is what your using you might try asking your question at
>microsoft.public.vc.language
>Regards,
>Greg Martin

>>Thanks

>>Phil



Tue, 11 Dec 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Strange problem about Add member wizard

2. Strange problem with function call - Anyone?

3. VERY strange problem using the function gets()

4. Strange problem for 2 versions of VS.Net

5. Strange problem in C

6. A strange problem with importing TLB

7. Strange problem with WebResponse

8. Really strange problem ... [looser-level]

9. strange problem

10. Strange problem

11. Strange problem

12. Very strange problems with files.

 

 
Powered by phpBB® Forum Software