| | |
Converting a Long Long to a Char Buff
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Solved Threads: 0
I tried functions as ltoa, itoa, etc and I took a look at my std libs and their is no ltoa conversion listes just the opposite.
I am dealing with a 64 bit value goinf to a array of chars and I do not see anything special for that.
short is support to but thier is no special call functions for it.
What calls do you suggest and I can look in my libs to see if they are there. This compiler is pretty old I think as I have found it missing other calls.
I am on contract here and not an employee.
I am dealing with a 64 bit value goinf to a array of chars and I do not see anything special for that.
short is support to but thier is no special call functions for it.
What calls do you suggest and I can look in my libs to see if they are there. This compiler is pretty old I think as I have found it missing other calls.
I am on contract here and not an employee.
>I am dealing with a 64 bit value goinf to a array of
>chars and I do not see anything special for that.
Don't just look at the headers, check the documentation. I'm reasonably sure that if the compiler supports long long, it provides a format specifier for sprintf as well.
>chars and I do not see anything special for that.
Don't just look at the headers, check the documentation. I'm reasonably sure that if the compiler supports long long, it provides a format specifier for sprintf as well.
New members chased away this month: 3
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Solved Threads: 0
•
•
•
•
>I am dealing with a 64 bit value goinf to a array of
>chars and I do not see anything special for that.
Don't just look at the headers, check the documentation. I'm reasonably sure that if the compiler supports long long, it provides a format specifier for sprintf as well.
I was just wondering if thier was a manual mathmatical way to do it?
Thanks Steve
>I was just wondering if thier was a manual mathmatical way to do it?
Well, long long is just another integer type, so converting it to a string is really no different from writing your own itoa function (or lltoa, as it were). If I were you[1], I would start looking for source code to itoa variations online (of which there are many). Chances are good you can change
[1] If I were me, which I am, I would write my own from scratch because I've done it before and have sufficient experience implementing libraries to trust my own skills over some random snippet I found on the web.
Well, long long is just another integer type, so converting it to a string is really no different from writing your own itoa function (or lltoa, as it were). If I were you[1], I would start looking for source code to itoa variations online (of which there are many). Chances are good you can change
int to long long and be ready to go. You might have to look out for range assumptions, but aside from that the conversion should be trivial.[1] If I were me, which I am, I would write my own from scratch because I've done it before and have sufficient experience implementing libraries to trust my own skills over some random snippet I found on the web.
New members chased away this month: 3
•
•
Join Date: Apr 2008
Posts: 9
Reputation:
Solved Threads: 0
•
•
•
•
>I was just wondering if thier was a manual mathmatical way to do it?
Well, long long is just another integer type, so converting it to a string is really no different from writing your own itoa function (or lltoa, as it were). If I were you[1], I would start looking for source code to itoa variations online (of which there are many). Chances are good you can changeinttolong longand be ready to go. You might have to look out for range assumptions, but aside from that the conversion should be trivial.
[1] If I were me, which I am, I would write my own from scratch because I've done it before and have sufficient experience implementing libraries to trust my own skills over some random snippet I found on the web.
Thanks I will look for that and I may have to do some bit shifting that I was trying to avoid! It just seems it is all catered to go from ascii to int, long, etc.
![]() |
Other Threads in the C Forum
- Previous Thread: Pointers and Arrays! (Horay!)
- Next Thread: Fixed to Floating point conversions
| Thread Tools | Search this Thread |
Tag cloud for C
* adobe api append array arrays bash binarysearch changingto char character cm copyanyfile copypdffile createcopyoffile createprocess() csyntax directory dynamic execv feet fgets file floatingpointvalidation fork frequency function getlogicaldrivestrin givemetehcodez global gtkgcurlcompiling gtkwinlinux highest histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list lowest matrix meter microsoft mqqueue multi mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scheduling segmentationfault send single socketprogramming spoonfeeding stack standard strchr string suggestions system test testautomation unix urboc user whythiscodecausesegmentationfault win32api windows.h windowsapi






