>Is that my program is wrong or wad?
Yes, it is. In more ways than just trying to plug in a piece of code. For starters, you are trying to write C++ code. From my understanding, you want the string with no repetitions to go in y, yet you print x, the logic of the loops can be simplified greatly with the use of the standard libraries as well.
Compare this with what you have, be sure to compile the program as C and not C++, try walking through each line and determine what it does, then test to see if that is what it does:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main ( void )
{
int i, len, current = 0;
char input[100], output[100] = {0};
fputs ( "Type in the string : ", stdout );
if ( fgets ( input, sizeof input, stdin ) == NULL ) {
fputs ( "Error reading input or no input\n", stderr );
exit ( EXIT_FAILURE );
}
len = strlen ( input );
for ( i = 0; i < len; i++ ) {
if ( memchr ( output, input[i], current ) == NULL )
output[current++] = input[i];
}
printf ( "The string without repeatitions is: %s", output );
return EXIT_SUCCESS;
}
-Prelude