0

So I have been getting this error for a while. I have looked through my code but cannot fine the issue. The full error I get is

1>ConsoleApplication132.obj : error LNK2019: unresolved external symbol "void __cdecl DNAtoRNA(char)" (?DNAtoRNA@@YAXD@Z) referenced in function _main

This is my code:

   // Program uses wave data to calcuulate steepness and average steepness for the year

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cctype>
#include <string>

using namespace std;

struct DNAnt{
    int adenine, cytosine, guanine, thymine;
    string strand;
    char allDNA[100][80];
};

void data2DNA(int * , int * , int * , int * , string);
void countDNA(int * , int * , int * , int * , string , bool *);
void DNAtoRNA(char );

int main()
{
    DNAnt DNA;

    data2DNA(&DNA.adenine, &DNA.cytosine, &DNA.guanine, &DNA.thymine, DNA.strand);

    ifstream inputFile;
    inputFile.open("C:\\Users\\mjass_000\\Desktop\\DNA.txt");

    for(int y=0; y<80; y++){                                                    //inputting information into array
        for(int x=0; x<100; x++){                                               //-----
            inputFile >> DNA.allDNA[x][y];                                      //-----
        }                                                                       //-----
    }                                                                           //-----

    DNAtoRNA(DNA.allDNA[100][80]);

    inputFile.close();
    cin.get();
    return 0;
}

void data2DNA(int *adenine, int *cytosine, int *guanine, int *thymine, string strand){

    ifstream inputFile;
    inputFile.open("C:\\Users\\mjass_000\\Desktop\\data.txt");

    ofstream outputFile;
    outputFile.open("C:\\Users\\mjass_000\\Desktop\\DNA.txt");


    int number, numA=0, numC=0, numG=0, numT=0, count=0;
    bool end=false;

    while (inputFile >> number){

        if(number==1){
            strand="A";
            outputFile << strand;                                                       //outputting to file
            countDNA(&numA, &numC, &numG, &numT, strand, &end);
            count++;
        }else if(number==2){
            strand="C";
            outputFile << strand;
            countDNA(&numA, &numC, &numG, &numT, strand, &end);
            count++;
        }else if(number==3){
            strand="G";
            outputFile << strand;
            countDNA(&numA, &numC, &numG, &numT, strand, &end);
            count++;
        }else if(number==4){
            strand="T";
            outputFile << strand;
            countDNA(&numA, &numC, &numG, &numT, strand, &end);
            count++;
        }
        if(count==10000){                                                                   //if it is the last number
            end=true;
            *adenine=numA;
            *cytosine=numC;
            *guanine=numG;
            *thymine=numT;
        }

    }
    outputFile.close();
    inputFile.close();

    return;
}

void countDNA(int *numA, int *numC, int *numG,int *numT, string strand, bool *end){

    if(strand=="A"){
        *numA+=1;
    }else if(strand=="C"){
        *numC+=1;
    }else if(strand=="G"){
        *numG+=1;
    }else if(strand=="T"){
        *numT+=1;
    }

    return;
}

void DNAtoRNA(char allDNA[100][80]){

    ofstream outputFile;
    outputFile.open("C:\\Users\\mjass_000\\Desktop\\RNA.txt");

    int totalT=0;

    for(int y=0; y<80; y++){
        for(int x=0; x<100; x++){
            if(allDNA[x][y]=='T'){
                totalT++;
            }
        }
        if(totalT>25){                                                  //if there are more than 25 T's
            for(int x=0; x<100; x++){                                   //-----
                if(allDNA[x][y]=='T'){                                  //-----
                    outputFile << "U";                                  //-----
                }else{                                                  //-----
                    outputFile << allDNA[x][y];                         //-----
                }                                                       //-----
            }                                                           //-----
        }else{                                                          //-----
            for(int x=0; x<100; x++){
                outputFile << allDNA[x][y];
            }
        }
        totalT=0;
        outputFile << endl;
    }


    outputFile.close();
    return;
}
  • 1
    `char allDNA[100][80] != char` Where does the idea come from that 8000 chars in an 2D array are the same thing as a single char? – deviantfan Dec 09 '15 at 03:28
  • `DNAtoRNA(DNA.allDNA[100][80]);` <- you know that's outside the array, right? – user253751 Dec 09 '15 at 03:30
  • Also, what's your question? – user253751 Dec 09 '15 at 03:32
  • Wait what do you mean that is outside the array? Why do I get that error? I googled it and it looks like people get that error if they miss spell variables or function declerations. – gmchips Dec 09 '15 at 03:34
  • @gmchips: In C++ (and C) array indexes are _zero-based_. If an array has `n` elements the valid indexes are `0..n-1`. If you ever find yourself using an array's size as an index value you probably have a bug. The last valid element in that array is `DNA.allDNA[99][79]` – Blastfurnace Dec 09 '15 at 03:42
  • @gmchips More precisely, you get that if you use some function or variable which does not exist, eg. because you spelled the name wrong. In your case, you have a function DNAtoRNA which takes an array of 8000 chars, but you want to use a DNAtoRNA which takes a single char. ... The thing mentioned my immibis is another, unrelated problem. – deviantfan Dec 09 '15 at 03:42
  • @deviantfan OH that is why. Thank you for the clear explanation :) – gmchips Dec 09 '15 at 03:46

0 Answers0