   Char and Float (Simple)
  How would you go about converting a float to something you can use with a char variable.like i have:char *strTemp="Hello";float aNumber = 2;now how would i get it to say: "Hello2" ? 
  Look up the itoa() and atoi() functions on Google.You may need to cast the float to int first, or there may be a special function for floats, can someone enlighten us on that? ;  sprintf(strTemp, "%s%f", strTemp, aNumber);will result in strTemp containing "Hello2"   EDIT: Syncronous post with AP...No, you use gcvt() for that.(Stolen from Programmer One)UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus   [edited by - Dragon88 on February 6, 2004 4:33:16 PM] [edited by - Dragon88 on February 6, 2004 4:33:54 PM];  Don''t use itoa. ;quote:Don''t use itoa.yeah, don''t use itoa....or printf, cout, cin, include, define, main() and everything else.Let him use what he/she wants to use ok.  Unless you have a reason....in which you can include with your post.my 3 cents. ;  Ignore this   [edited by - tool_2046 on February 6, 2004 4:51:54 PM];quote:strcat strTemp with atof(aNumber). atof returns a char * version of a floating No.  atof returns a floating point variable.try this:char buffer[ 20 ];fprintf( buffer, "%s%.2f", strTemp, aNumber );printf( "%s", buffer ); ;  You are right and I''m retarded, sorry. sprintf is definitely the way to go. I''ll try to use my brain in future postings.... ;  So in essence, you are telling him what I said?   (Stolen from Programmer One)UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus ;#include<sstream>#include<string>#include<iostream>int main(){float f=2.f;std::ostringstream o;o << "Hello" << f;std::string s = o.str();std::cout << s;} 