Off-topic Talk Where overpaid, underworked S2000 owners waste the worst part of their days before the drive home. This forum is for general chit chat and discussions not covered by the other off-topic forums.

quick C question

Thread Tools
 
Old Sep 22, 2001 | 03:17 PM
  #1  
mingster's Avatar
Thread Starter
Registered User
20 Year Member
 
Joined: Oct 2000
Posts: 10,134
Likes: 0
From: Baltimore
Default

does anyone know how you convert strings to integers and vice versa in C?
Reply
Old Sep 22, 2001 | 03:31 PM
  #2  
naishou's Avatar
Registered User
 
Joined: Apr 2001
Posts: 3,936
Likes: 0
From: Sydney
Default

Originally posted by mingster
does anyone know how you convert strings to integers and vice versa in C?
int atoi(const char*); (also look at sscanf)

sprintf(char*, "%d", int*);

(or something) This is from memory and it's been a while.
Reply
Old Oct 6, 2001 | 07:07 PM
  #3  
AGoodbar's Avatar
Registered User
20 Year Member
 
Joined: Dec 2000
Posts: 31
Likes: 0
From: G'ville
Default

For that one step or permanently - for the one step it would be something like this

to add character 'a' (var name char) and integer 3 (var name three) into integer variable var it would be

var = int(char) + int(three)
Reply
Old Oct 6, 2001 | 09:14 PM
  #4  
amartin's Avatar
Registered User
20 Year Member
 
Joined: Nov 2000
Posts: 1,865
Likes: 0
From: Austin
Default

Please post exactly what you want to convert (or an example there of) and I'll be happy to help out... atoi and itoa and sscanf are easy solutions... There are many others depending on your needs... I'll provide an example based on your sample.
-- Aaron
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
wicky
The Corner
875
Jan 31, 2010 11:07 AM
gomarlins3
Off-topic Talk
31
Sep 3, 2003 06:58 AM
The Raptor
The Corner
4
May 19, 2002 02:05 AM
Muz
Off-topic Talk
10
Jan 27, 2002 05:54 AM
mingster
Off-topic Talk
27
Nov 7, 2001 07:55 PM




All times are GMT -8. The time now is 05:35 PM.