This code snipplet will find the placement of each letter in a array(string), from another array(character set). For example:
the input would be something like this:
string[256] = "gfdc"
chrset[256] = "abcdefg"
and the output would be:
num[256] = 6, 5, 2 and 3

#include <stdio.h>
#include <string.h>

int main() {
	char string[256];	//This will hold out string
	char chrset[256];	//this will hold the character set
	int num[256];		//This will hold the result
	int count = 0;		//This is just for loops
	printf("Please enter a String: ");
	scanf("%s", string);
	printf("Please enter a Character set: ");
	scanf("%s", chrset);		//Get user input for the string & chrset
	//This will load the placements into num[]
	while(string[count] != 0) {
		num[count] = ((strchr(chrset, string[count])) - (int)chrset);
		count++; }

	count = 0;	//This will print out the placements
	while(count != strlen(string)) {
		printf("%c is in %d\n", string[count], num[count]);
		count++; }

	printf("Press any key to quit ...\n");
	return 0; }

Wow, how much my programming has canged over a few months! It should compile, but if not, try changing line 17 to:

num[count] = ((strchr(chrset, string[count])) - chrset);

Yeah I know, this isnt really an example of good programming practice, but it was a while ago when I was still learning C. :)

The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.