Thread: (char * to int) and (int to char *)

  1. #1
    Registered User madsmile's Avatar
    Join Date
    Feb 2002
    Posts
    26

    (char * to int) and (int to char *)

    How do i convert a char * to a number

    like char * to int ???
    and int to char * ???

    do i have to program the commando or c got one?

    (btw where do i ask question about borland c v3.1, here? or in other forum??)
    MADSmile
    ICQ #3653692
    (i'm running Borlad C++ Ver 3.1 under MSDOS)

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    129
    char *s = "123";
    int i = atoi(s);
    char ........ = itoa(i);

    Guess you could ask the Borland q here....

  3. #3
    Sayeh
    Guest
    Are you trying to convert a string (like "1234") to a number, or are you trying to get the address of the string?

    If you are trying to do the latter, then:

    Code:
    char   *myString;
    long   myNum;
    
    myString = 0x00A70388;
    
    myNum = (long)myString;
    enjoy.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  3. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  4. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM