C++: Can someone help me out?
By mchu519
@mchu519 (465)
United States
November 19, 2006 1:33am CST
How would you convert a string "1234" to int "1234"? I appreciate it.
4 responses

@saumav (180)
• India
15 Dec 06
the prototype of atoi(alphabet to integer) is:
int atoi(const char *);
So string datatype won't work on it
u can use it like this way:
char *str="1234";
int no=atoi(str);
printf("\n%d", no);
But this method is deprecated these days.
The better method is:
char *str="1234";
int no;
sscanf(str, "%d", &no))
printf("%d", no);
and if u want to do it in C++ there's a different way.
Do u want 2 know it?
Tell me if it helped u

@mchu519 (465)
• United States
16 Dec 06
Thanks, but I used an alternative way that is a lot more complicated. I have already submitted the programming project. Its suppose to be a database program where I can retrieved records by entering a unique id. This programmed can load a bunch of records, add one record a time, list all the records in database, show a record at a time with detail, and delete a record. I got full marks.
Now I have to do the same program, but use a more efficient method, which is B-tree. I have trouble with this one. Can anyone give me their source code for B-tree? Thanks.

