Được gửi bởi
cntt19001570
// thêm ký tự c vào đầu xâu bị lỗi ,in ra chỉ có ký tự c
#include<stdio.h>
#include<string.h>
#include<conio.h>
char *Them_kt(char *str1, char c);
int main()
{
char *xau="Diendantinhoc";
char kt='1';
clrscr();
printf("\nXau da them:%s",Them_kt(xau,kt));
getch();
return 0;
}
char *Them_kt(char *str1, char c)
{
char *temp;
int i,dai;
dai=strlen(str1);
strcpy(temp,"");
/*for (i=dai;i>=0;i++)*/
fo(i=0;i<=dai;i++)
{
/*temp[i+1]=str1[i];*/
if(i!=0)
temp[i]=str[i];
}
temp[dai+2]='\0';
/*temp[0]=c;*/
temp[0]='c' //gan dia chi ky ty c cho con tro temp[0]
return temp;
}
Bookmarks