Hi
Say you have to strings, "final" and "input". You use cin.getline to get the value of input. You want final to be like: "./pics/" input ".bmp" but how do you add the input string in the middle of final??
Thanks.
Hi
Say you have to strings, "final" and "input". You use cin.getline to get the value of input. You want final to be like: "./pics/" input ".bmp" but how do you add the input string in the middle of final??
Thanks.
...
You can use the c runtime string functions such as below:
Code:#include "stdafx.h" #include <stdlib.h> #include <iostream> using namespace std; int main() { char szFinal[ _MAX_PATH ] = { '.', '/', 'p','i','c','s','/' }; char szInput[ _MAX_PATH ] = { 0 }; cout << "Enter a something: "; cin.getline( szInput, 80 ); strcat( szFinal, szInput ); strcat( szFinal, ".bmp" ); cout << szFinal << endl; return 0; } // end