storing a long type in an array....

This is a discussion on storing a long type in an array.... within the C Programming forums, part of the General Programming Boards category; hey guys i tried to store a long type character by character in an array and this gives me heat....here ...

  1. #1
    Registered User
    Join Date
    Nov 2011
    Location
    Douala, Cameroon
    Posts
    190

    Angry storing a long type in an array....

    hey guys i tried to store a long type character by character in an array and this gives me heat....here is my code:for (int i = 0; i < MAX; i++) arrray[i] = (long) resultor memcpy(array, result, 100);but this gives me error messages...

  2. #2
    Registered User
    Join Date
    Nov 2011
    Location
    Douala, Cameroon
    Posts
    190
    i was thinking of using a while loop and the /1000 and %1000 to sort the characters and store them in the array.....is it better???

  3. #3
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Assuming you really want the "characters" of the number, this would normally be done something like this.
    Code:
    char str[32];
    long result = 123456789;
    sprintf(str, "%ld", result);  // note that's an ell, not a one
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  4. #4
    Registered User
    Join Date
    Nov 2011
    Location
    Douala, Cameroon
    Posts
    190
    yes thats it ........ thanks for the help @oogabooga.... this is the answer.......

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 'long long' type and printf() (on AIX 5.3)
    By alex5161 in forum C Programming
    Replies: 5
    Last Post: 12-16-2011, 03:05 PM
  2. Storing a very long number
    By valthyx in forum C Programming
    Replies: 21
    Last Post: 08-08-2011, 12:52 PM
  3. Replies: 1
    Last Post: 10-11-2010, 01:53 AM
  4. Storing long strings?
    By thebudbottle in forum C++ Programming
    Replies: 1
    Last Post: 03-09-2005, 05:10 PM
  5. Is long long int a valid Data Type
    By shiv_tech_quest in forum C Programming
    Replies: 2
    Last Post: 11-12-2003, 07:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21