Since this is homework (probably) you're not getting the answer, but here is a pretty good start:
Code:
#include <stdio.h>
#include <string.h>
static void printUnique(const char * a, size_t m, const char * b, size_t n);
int main(void)
{
char str1[] = "Hello";
char str2[] = "Hallo";
/* what's in str1 that isn't in str2 ? */
printUnique(str1, strlen(str1), str2, strlen(str2));
/* what's in str2 that isn't in str1 ? */
printUnique(str2, strlen(str2), str1, strlen(str1));
return 0;
}
static void printUnique(const char * a, size_t m, const char * b, size_t n)
{
size_t i, f;
int found = 0;
/* print unique from a that aren't in b */
for(i = 0; i < m; i++)
{
found = 0;
for(f = 0; f < n; f++)
{
if(a[i] == b[f])
{
found = 1;
break; /* no point checking the rest */
}
}
if(found == 0)
printf("%c is in a but not b...\n", a[i]);
}
return;
}
/* output:
e is in a but not b...
*/
If you have to use pointers just use a pointer to point at a[i], ie
Code:
char * ptr;
/* ... */
for(i = 0; i < m; i++)
{
ptr = &a[i];
printf("value is %c...\n", *ptr);
/* ... */