0

hi, i just want the join two strings by checking the second string a non vowel word.
suppose,

str1="hello";
str2="world";

here i want the neglect the vowel characters in the second string.
so, i have used 'while loop' for checking each character in the str2.

i used the code something like this,

void main()
{
    char *str1="hello";
    char *str2="world";
    char *s;
    clrscr();
    while(*str2)
    {
        *s=*str2;
        strcat(str1,s);
        *str2++;
    }

    printf("%s",str1);
    getch();
}

required output:hellowrld.(after omitting the vowel character 'o' in str2).

here i didnt check the vowels, but he problem is

i am getting some junk values in the loop.

can anyone tell me what is the mistake. or what is the right way to do this.

Edited by Dani: Formatting fixed

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by gerard4143
0

Firstly, your trying to concatenate onto a string that's immutable

str1="hello";/*creates a immutable c string*/

strcat(str1,s);/*Can't do this for two reasons, one - str1 isn't big enough and two
str1 in immutable*/

Edited by gerard4143: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.