"strstr" question

I'm trying to do a substitution cipher, but I cannot get it to output the translated code. This is what I have right now but I am wondering if I could use strstr to search for the letter in the encrypter key and output it that way. This is what I have
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
cout << endl << "Original Alphabet:  ";
int x = 0;
for ( char i = 'A'; i <= 'Z'; i++)
{
	original[x++] = i;
}
for (int i = 0; i < 26; i++)
{
	cout << original[i];
}
//encrypted alphabet
int count;
cout << endl << "Encrypted: ";
for (count = 0; count < SUBCIPHER; count++)
{
	inFile >> newAlpha[count];
}
	for (int i = 0; i < 26; i++)
{
	cout << newAlpha[i];
}
int count=0;
char decrypt[LINE_SIZE];
inFile.getline(decrypt, LINE_SIZE);
inFile >> decrypt;

while (inFile)
{
	cout << endl << "\n   ";	
	while (decrypt[count] != '\0')
	{
		cout << decrypt[count];
		count++;
	}
	count = 0; //incrementer
	int counter = 0; //increments newAlpha
	cout << "\n";
	while(toDecode[count] != '\0')
	{
		int lineLength;
		lineLength = strlen(decrypt);
		do
		{ 
			if(decrypt[count] == newAlpha[counter])
			{
				decrypt[count]= alphabet[counter];
				cout << alphabet[counter];
			}
			else if (decrypt[count] == ' ')
			{
				decrypt[charCount] == ' ';
			}
			else
			{
				counter++;
			}
		}while ( decrypt[count] < lineLength);
		count++;				
		}

I tried this, but there's an overloaded error on the strstr.
1
2
3
4
5
6
7
8
9
10
11
12
int lineLength;		
char *strPtr = NULL;
lineLength = strlen(toDecode);

	for (counter=0;counter < lineLength; counter++)
	{
	strPtr = strstr(fixedSub[counter],toDecode[charCount]); 
        //?? not sure what to do here
		if (strPtr != NULL)
                     break; // or here
			}
Last edited on
Topic archived. No new replies allowed.