The question is:
Write a program to a string from the user.
Also ask the user to enter a character.
Then find the position of first occurrence of that character in the string and then copy the string from this position to new string.
And that my code:
using namespace std;
char x; int ch;
char y; char count;
for(int k=0; k<count; k++)
Please try to indent your code and put it within code tags.
Firstly, I do not see any use of the variable count.
Secondly once you find a match of the character in the input string, you should break out of the while loop.
1 2 3 4 5 6 7 8 9 10 11
for (; x[i] != '\0'; i++) // copy the remaining characters from the matched position
y[i-j] = x[i];
y[i-j] = '\0';
// now you can output the array 'y'.
The above code is just to give you an idea and it may contain some bugs.