aspose file tools*
The moose likes C / C++ and the fly likes convert char pointer to int gives segmentation fault Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Languages » C / C++
Bookmark "convert char pointer to int gives segmentation fault" Watch "convert char pointer to int gives segmentation fault" New topic
Author

convert char pointer to int gives segmentation fault

Grace Green
Ranch Hand

Joined: Nov 08, 2010
Posts: 68

input is something like "word-2"
How do I convert from char pointer to int ?

Grace Green
Ranch Hand

Joined: Nov 08, 2010
Posts: 68
made some modifications
inside the if statement:



Why ?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

"50" is the ASCII value of the numeral "2".

ASCII


[Jess in Action][AskingGoodQuestions]
Grace Green
Ranch Hand

Joined: Nov 08, 2010
Posts: 68
Ernest Friedman-Hill wrote:"50" is the ASCII value of the numeral "2".

ASCII


Doh !!
In assigning

version = *tmp_result;

how do I make the int version be equal to "2", and not to the ascii value of the numeral ?
Grace Green
Ranch Hand

Joined: Nov 08, 2010
Posts: 68


I tried atoi like in



but got the warning: passing arg 1 of `atoi' makes pointer from integer without a cast
Grace Green
Ranch Hand

Joined: Nov 08, 2010
Posts: 68



got it:




tmp_result is a pointer
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: convert char pointer to int gives segmentation fault