int main(int argc, char *argv[]) {
if(argc!=3) {
printf("You must pass exactly three para \n");
return 0;
}
char *buffer = argv[1];
//printf("The length of the buffer string is %d\n",buflen);
char *mystring = argv[2];
//printf("The length of the user string is %d\n",len);
addstring(buffer, mystring);
return 0;
}
int addstring(char *buffer, char *mystring)
{
int buflen = strlen(buffer);
int len = strlen(mystring);
char *dest;
*dest = (char *)malloc(buflen + len + 1);
printf("The size of destination is %lu\n",sizeof(dest));
dest = strcpy(dest,buffer);
dest = (dest + buflen);
dest = strcpy(dest,mystring);
printf("The final string is %p",dest);
return 0;
}
在上面的代碼中,函數addstring(..)
鞋這個錯誤Assignment makes integer from a pointer without a cast
。我知道我正在接受一個指針的值並將其放入整數,但我該如何解決這個錯誤?賦值使指針無整型指針
你已經做了'* DEST =(的char *)malloc的(buflen + LEN + 1);'而不是'DEST =的malloc(buflen + LEN + 1);' – Chandru 2014-10-31 07:16:46
你需要'#include'和'#include ' –
2014-10-31 08:12:27