| | |
how to save big number into array
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jan 2008
Posts: 3,813
Reputation:
Solved Threads: 501
C++ Syntax (Toggle Plain Text)
int char2int(char c) { switch(c) { case '0': { return 0; } case '1': { return 1; } case '2': { return 2; } case '3': { return 3; } case '4': { return 4; } case '5': { return 5; } case '6': { return 6; } case '7': { return 7; } case '8': { return 8; } case '9': { return 9; } } }
Take advantage of the fact that '0' through '9' are contiguous on the ASCII chart and that you can subtract characters.
C++ Syntax (Toggle Plain Text)
int char2int(char c) { if (c < 48 || c > 57) return -1; // signifies non-digit/invalid return c - 48; // '0' is 48 in ASCII }
![]() |
Similar Threads
- StreamReader and Position (In VB) (VB.NET)
- Shopping Cart Not Working (ASP.NET)
- Working with doubles, having some troubles (C++)
- File Reading (C++)
- memory management in wndows 2000 (Windows NT / 2000 / XP)
- Is a variant return type possible in C++? (C++)
- fibonacci (C++)
- Pascal assistance (Pascal and Delphi)
- Source Code that don't work? (Java)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
Other Threads in the C++ Forum
- Previous Thread: Binary search
- Next Thread: quick pointer question
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct temperature template templates text tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets







