Hi all;
So I have an assignment that needs me to take in a file that simply has a string of characters
(for example: aacgttatgtgtaaccagaactgatgt) and output a file that assigns each letter a value (for example, a =1, c=2, etc.) I've been thinking about how to go about doing this, and settled on somehow converting the string into a character array, which i can then use to call a character and assign it a value.
so far, to just feel like I'm outputting something, all i have it doing is just assigning the string to "test", and printing out "test" into the output file. I set up some error messages, but those are unimportant for now. I'm particulary confused on how I would create and use the array. Am i going about this completely the wrong way? Thanks in advance.Code:int main (int argc, char*argv[]) { if (argc != 3) //if there are an incorrect number of arguments { cerr << "\n\tIncorrect usage.\n" << "\tCorrect syntax: " << argv[0] << " inputFile outPutFile\n\n"; exit(1); } ifstream fin; ofstream fout; fin.open (argv[1]); //opens input file from command line if (fin.fail()) //if file cannot open { cerr << "Could not open " <<argv[1] << endl; exit(1); } fout.open (argv[2]); if (fout.fail()) //if file cannot open { cerr << "Could not open " <<argv[2] << endl; exit(1); } string test; int characters = test.size(); char inputArray[299]; //arbitrary size of array fin >> test; for (int i =0; i <= characters; i++) { fout << inputArray[]; } fout << test<< endl; fin.close(); fout.close(); return 0; }