静的文字バッファーを使用して、文字列 array1 の別の動的文字配列の末尾に文字列 array2 の動的文字配列を追加する独自の追加関数を作成しています [50]。しかし、コンパイラは次のエラーを生成します。問題を理解しようとしましたが、解決策が見つからないようです。あなたの助けは非常に高く評価されます。Dev-C++ を使用しています。コードは以下です。
#include <iostream>
using namespace std;
char *Appendstring(char *a, char *b) // will append b to the end of a
{
static char buffer[50];
char *p=buffer=*a++; //[Error] incompatible types in assignment of 'char' to 'char[50]'
//[Error] invalid conversion from 'char*' to 'char'[-fpermissive]
p--;
while(*p++=b++);
p--; //append
while(*p++=*c++);
return buffer;
}
int main ()
{
string str="Displaying: ";
string add=" Summer is coming";
Appendstring(str, add);
return 0;
}