![]() |
|
#1
|
|||
|
|||
Convert Integer to StringCPP / C++ / C Code:
the last line gives an error. Can someone help me solve this. Last edited by LuciWiz : 17-Aug-2005 at 10:47.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#3
|
|||
|
|||
|
explain the errors you are getting.
Although they seems like an annoyance, you should learn to rely n them for information. Are they run-time or compile-time errors? Provide more information for a better response. |
|
#4
|
|||
|
|||
|
CPP / C++ / C Code:
this should work. Last edited by LuciWiz : 26-Mar-2006 at 12:57.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#5
|
|||
|
|||
|
Quote:
There is one thing I like about this, and two that I don't like: I much prefer the standard library sprintf() to the nonstandard _atoi(), so I like that part, but I don't know what you mean by "work". It tries to store an unknown value into an undefined memory address. What do you think it stores and where does it store it? As L7Sqr indicated, if the original poster would show his expectations (what is he trying to do) and his environment (what compiler, what error messages) maybe we could give more helpful advice. Regards, Dave |
|
#6
|
|||
|
|||
|
Quote:
1. You declare an array of char that has one member. That's not illegal, but why would anyone want an array with only one member? 2. You store something (a single char) in an address that is outside the array That is illegal, since the only legal address will be at str[0]. 3. The original post used the non-standard library function _itoa(). Compilers that have library support for this function use it to convert an int to a string, whereas the standard library function atoi() converts a string to an int. Maybe that is what the original poster needs, but how can we tell? As L7Sqr implied, the original poster needs to tell us more. Regards, Dave P.S. I know, I know: Sometimes I am so eager to try to help someone that I jump to a conclusion and try to answer a question he didn't ask. I'm working on it. We are all trying to help, and your intentions are admirable, but I think L7Sqr has the right approach: let them tell us what they mean, then try to help. |
Recent GIDBlog
Writing a book by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help wit my source code compiler errors | Krandygrl00 | C++ Forum | 1 | 06-Jun-2005 09:14 |
| Converting string to float | CT++ | C++ Forum | 2 | 10-May-2005 12:29 |
| How to convert int to string in MFC? | george | MS Visual C++ / MFC Forum | 15 | 14-Apr-2005 12:18 |
| Convert Unsigned short int to a string... | Pissus | C++ Forum | 2 | 11-Jan-2005 09:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The