Today I got back to a little programming after a long time.


Ok, the thing I am trying to do is read a DNA-like code from a text file. It consists out of A, B, C and D's This all works.

Because every three letters of the code together have a meaning I need to read the first three letters from the file, look which combination it is and do something. I try to use an if statement.


Code:
char triplet[3];

[...]

if ( strncmp ( triplet, "ABC", 3 ) == 0 )[/quote] { [...] }
This has the problem that "ABC" isn't a constant. So I change it to

Code:
char strABC[] = { "ABC"};
if ( strncmp ( triplet, strabc, 3 ) == 0 )[/quote] { [...] }

There is no difference between strcmp and strncmp, it seems.

This doesn't seem to work though the program clearly says that triplet[1] is A, triplet[2] is B and triplet[3] is C.

Strangely enough if I give the command cout<<triplet I get strange symbols on stopts 0 4 5 and 6.

Ok, I am being stupid here, I guess. What am I doing wrong?