Re: [Dev-C++] Casting of int to string
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Philip B. <phi...@pb...> - 2007-05-07 06:35:10
|
This will do the job. char outputstring[32]; sprintf(outputstring, "%d", integer); It basically prints your integer into the character array, as long as there is enough space to hold it. This method works both in C and C++. There are other methods such as stringstream, but they only work in C++. If you're compiling a C program, for this function to work you need to include stdio.h and for C++ it is cstdio. Regards Philip Bennefall ----- Original Message ----- From: "Jan Mura" <jan...@vo...> To: <dev...@li...> Sent: Monday, May 07, 2007 8:26 AM Subject: [Dev-C++] Casting of int to string > Hello, > > I would like to compare an integer with a string using strcmp(). So I need > to cast the int type to string (*char). Is there some commone way how to > do > it. Should I use & operator and adress of int in teh function? Or > something > else? > > Thank you very much > > Jan Mura > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |