Here you are.
#include <stdio.h>
int main(void)
{
char a[] = { 'a', 'b', 'c', 'd', 'a', 'a', 'b', 'd', 'c', 'c' };
const size_t N = sizeof( a ) / sizeof( *a );
for ( size_t i = 0; i < N; i++ )
{
size_t j = 0;
while ( j != i && a[j] != a[i] ) ++j;
if ( j == i ) printf( "%c ", a[i] );
}
putchar ( '
' );
return 0;
}
The program output is
a b c d
Or for example if you have a character array that contains a string then the same approach can be implemented the following way.
#include <stdio.h>
int main(void)
{
char s[] = { "abcdaabdcc" };
for (const char *p = s; *p != ''; ++p )
{
const char *prev = s;
while ( prev != p && *prev != *p ) ++prev;
if ( prev == p ) printf( "%c ", *p );
}
putchar ( '
' );
return 0;
}
The program output is the same as shown above that is
a b c d
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…