0

I am new to the world of C but am enthusiastic nonetheless, so pardon me if this appears to be a particularly basic question...

I am attempting to write a program that uses DNA strands.. which consist of A,T,C,and G characters...

The user is prompted to input a DNA strand.

After they have input the string of a certain length I want to use a user defined function to check the string and ensure the fact that it doesn't contain any letters that are not A,T,C, or G. If it does contain an invalid character I want to alert the User... If it does not contain any characters other than A,T,C, or G then there will be no problem and the program will continue...

any help regarding this would be greatly appreciated.

David

4
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by Aia
1

Or you could just use the strspn() function: if (strspn( dnaStr, "AaTtCcGg" ) < strlen( dnaStr )) puts( "error in DNA" );

Votes + Comments
Aye
0

Or you could just use the strspn() function: if (strspn( dnaStr, "AaTtCcGg" ) < strlen( dnaStr )) puts( "error in DNA" );

@BensonRoss, make sure you include <string.h> for strspn() and strlen().

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.