Note that there are some explanatory texts on larger screens.

plurals
  1. POshort function in c - don't understand what's wrong
    text
    copied!<p>I'm writing a function that just calculates the "complementary" strand of DNA, meaning replaces C with G, T with A, and so on. </p> <p>this is what I wrote:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;string.h&gt; #define SIZE 70 int isLegitSequence(char sequence[]); void getComplementaryStrand(char complementary[],char sequence[]); int findSubSequence(char sequence[],char subsequence[]); int findSubComplementary(char sequence[],char subcomplementary[]); void cutSequence(char sequence[],char tocut[]); void checkDNAList(char data[][SIZE],int rows,char sequence[]); void main(){ char dnaSequence[SIZE]; char compDnaSequence[SIZE]; printf("Enter a DNA Strand\n"); gets(dnaSequence); printf("%d\n",isLegitSequence(dnaSequence)); getComplementaryStrand(compDnaSequence,dnaSequence); puts(compDnaSequence); } int isLegitSequence(char sequence[]){ int i=0; while (sequence[i]){ if(sequence[i]=='A'||sequence[i]=='C'||sequence[i]=='G'||sequence[i]=='T'); else return 0; i++; } return 1; } void getComplementaryStrand(char complementary[SIZE],char sequence[SIZE]){ int j=strlen(sequence)-1,i; for(i=0;sequence[i];i++,j--){ if(sequence[i]=='A') sequence[j]='T'; else if(sequence[i]=='C') sequence[j]='G'; else if(sequence[i]=='G') sequence[j]='C'; else sequence[j]='A'; } complementary[strlen(sequence)]='\0'; } </code></pre> <p>However, this is what I get when I run the program:</p> <pre><code>Enter a DNA Strand CGCTC 1 ╠╠╠╠╠ Press any key to continue . . . </code></pre> <p>This is my first time using functions, so I'm not sure what I did wrong here. Would appreciate help, but in the scope of my understanding, namely very very basic. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload