P
poison.summer
Here is my short code to implement such function:
Check whether the string starts with "12", if not
add "12" in front of the string.
Is the code good? or any better way to do it?
Thanks a lot!
#include <string.h>
int main()
{
char A[10];
char B[10];
strcpy(A,"abcdef\0");
printf("A=(%s)\n",A);
if((A[0]=='1')&&(A[1]=='2'))
printf("A=(%s)\n",A);
else
{
B[0]='1';
B[1]='2';
B[2]='\0';
strcat(B,A);
printf("B=(%s)",B);
}
}
~
~
Check whether the string starts with "12", if not
add "12" in front of the string.
Is the code good? or any better way to do it?
Thanks a lot!
#include <string.h>
int main()
{
char A[10];
char B[10];
strcpy(A,"abcdef\0");
printf("A=(%s)\n",A);
if((A[0]=='1')&&(A[1]=='2'))
printf("A=(%s)\n",A);
else
{
B[0]='1';
B[1]='2';
B[2]='\0';
strcat(B,A);
printf("B=(%s)",B);
}
}
~
~