Question: Using only stdio.h, string.h and stdlib.h libraries how would I go about implementing this?

I'm quite new to programming so please bear with me!

Answer: 
1. Allocate a new `char` array of the same length as your string. Convince yourself that this is enough space. Don't forget the NUL.
2. Loop through the string, copying to the new string only those characters that are alphanumeric. You can't do this portably without also including `<ctype.h>` and using a function/macro from that header, unless you're going to enumerate all characters that you consider alphanumeric.
3. Again, don't forget the NUL.
The best way is to use the `isalnum()` from `ctype.h` but now that is not an option, I have written a not-standard/non-portable function called `isalnum_not_prefered()` which is the equivalent of `ctype.h`'s `isalnum()`. 

```
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

int isalnum_not_prefered(char s) 
{
    if((s >= 'A' && s <= 'Z') || 
       (s >= 'a' && s <= 'z') || 
       (s >= '0' && s <= '9')) 
        return 1;
    return 0;
}

int main(void)
{
    char str[] = "this!234$#&@#$^is5@#$a#@$4677~=_?}valid2234kjstring";
    int len = strlen(str);
    int i, j=0;

    char *newstr1 = NULL;
    char *newstr2 = NULL;

    if ((newstr1 = (char *) malloc(sizeof(char) * len + 1)) == NULL) {
        printf("unable to allocate memory \n");
        return -1;
    }

    for (i=0 ; i<len ; i++) {
        if (isalnum(str[i])) {
            newstr1[j] = str[i];
            j++;
        }
    }
    newstr1[j] = '\0';

    if ((newstr2 = (char *) malloc(sizeof(char) * len + 1)) == NULL) {
        printf("unable to allocate memory \n");
        return -1;
    }

    j=0;
    for (i=0 ; i<len ; i++) {
        if (isalnum_not_prefered(str[i])) {
            newstr2[j] = str[i];
            j++;
        }
    }
    newstr2[j] = '\0';

    printf("string  : %s \n", str);
    printf("result1 : %s \n", newstr1);
    printf("result2 : %s \n", newstr2);

    free(newstr1);
    free(newstr2);

    return 0;
}

```

Points to note:

1. strings in `C` is terminated with `\0`. So the new string that your are populating should also terminate with `\0`
2. `malloc()`'ed memory must be `free()`'ed
3. `malloc()` errors should be handled
4. this code is not portable as it assumes the machines character set to be `ASCII`. If the hardware supports some other character set (say `EBCDIC`) then this may not work as expected.

Hope this helps!