| | |
Converting Int to Const Char
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jul 2005
Posts: 164
Reputation:
Solved Threads: 5
int to const char....
int a=12345;
const char c = a &0xff;
string to const char....
string s("some bollux");
const char c = s[0];
I suspect you meant const char* as the above examples although correct will probably be not what you intended.
string to const char* ....
string s("some bollux");
// then when you need the const char* from this you call strings member func c_str().
if (strcmp(s.c_str(),"some bollux")== 0)
{}
int to const char* ....
int a = 12345;
ostringstream os;
os<<a;
string s = a.str();
if (strcmp(s.c_str(),"12345")== 0)
{}
etc.
int a=12345;
const char c = a &0xff;
string to const char....
string s("some bollux");
const char c = s[0];
I suspect you meant const char* as the above examples although correct will probably be not what you intended.
string to const char* ....
string s("some bollux");
// then when you need the const char* from this you call strings member func c_str().
if (strcmp(s.c_str(),"some bollux")== 0)
{}
int to const char* ....
int a = 12345;
ostringstream os;
os<<a;
string s = a.str();
if (strcmp(s.c_str(),"12345")== 0)
{}
etc.
![]() |
Similar Threads
- first cannot conver std::string to const char, now runtime error! (C++)
- converting int to char in C (C)
- convert int back to char (C)
- AnsiString to Const Char* (C)
Other Threads in the C Forum
- Previous Thread: Need help changing code
- Next Thread: laern c seriously
Views: 10958 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C
#include * .net append array arrays bash binarysearch changingto char character cm copyanyfile copypdffile createprocess() database directory drawing dynamic execv feet fgets file floatingpointvalidation fork function functions getlogicaldrivestrin givemetehcodez global grade graphics gtkwinlinux histogram homework i/o ide include infiniteloop initialization input interest intmain() iso keyboard kilometer lazy license linked linkedlist linux list looping loopinsideloop. lowest matrix meter microsoft mqqueue mysql oddnumber odf open openwebfoundation overwrite pause pdf pointer pointers posix power process program programming pyramidusingturboccodes read recursion recv recvblocked reversing segmentationfault single socket socketprogramming spoonfeeding standard strchr string student suggestions system test testing threads unix urboc user whythiscodecausesegmentationfault win32api windowsapi





