I have already tried it and i know it is a bit rude to ask but I am really new to c... please someone help
1.
void strcpy_upper(char *dest, const char *src);
which copies string src
into string dest
converting all lowercase letters in a text string to uppercase.
2.
void strremdup(char* dest, const char* src);
which copies the string src
into string dest
ignoring repeated adjacent characters.
3.
void swap_random(char* str);
which swaps characters randomly in string src
.
my attempt at the first one :
void mystrcpy(char *dest, const char *src)
{
int i;
for (i = 0; src[i] != '\0'; i++)
{
dest[i] = src[i];
}
dest[i] = '\0';
printf("%c", *src);
}
int main()
{
char P[5] = "hell";
char K[5];
mystrcpy(P, K);
system("pause");
return 0;
}
转载于:https://stackoverflow.com/questions/53249296/how-to-write-this-function-in-c-using-character-array-and-pointers