A
Amira
Could somebody possibly find out why I do not manage to compile this
code with g++ under linux? For any help I am really greatful! Cheers,
pa
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
#include <cassert>
using namespace std;
using std::cout;
//using std::cout;
//using std::cin;
//using std::endl;
int molWeight_;
//char name_[10], family_[10];
char *protName_;
char *protFamily_;
const char *protName, *protFamily;
int main(){
protName_ = new char[strlen( protName ) + 1 ];
assert(protName_ != 0 );
strcpy(protName_, protName);
protFamily_ = new char[strlen( protFamily ) + 1 ];
assert(protFamily_ != 0 );
strcpy(protFamily_, protFamily);
cout << "Enter protein name: ";
cin >> protName_;
cout << "Enter molecular weight: ";
cin >> molWeight_;
cout << "Enter protein family: ";
cin >> protFamily_;
//delete [] protName_;
//delete [] protFamily_;
ofstream myfile;
myfile.open ("protein.txt");
myfile << "<Protein>\n" << " <molWeight>" << molWeight_ << "</
molWeight>"
<< "\n</Protein>" << endl;
myfile.close();
return 0;
}
code with g++ under linux? For any help I am really greatful! Cheers,
pa
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
#include <cassert>
using namespace std;
using std::cout;
//using std::cout;
//using std::cin;
//using std::endl;
int molWeight_;
//char name_[10], family_[10];
char *protName_;
char *protFamily_;
const char *protName, *protFamily;
int main(){
protName_ = new char[strlen( protName ) + 1 ];
assert(protName_ != 0 );
strcpy(protName_, protName);
protFamily_ = new char[strlen( protFamily ) + 1 ];
assert(protFamily_ != 0 );
strcpy(protFamily_, protFamily);
cout << "Enter protein name: ";
cin >> protName_;
cout << "Enter molecular weight: ";
cin >> molWeight_;
cout << "Enter protein family: ";
cin >> protFamily_;
//delete [] protName_;
//delete [] protFamily_;
ofstream myfile;
myfile.open ("protein.txt");
myfile << "<Protein>\n" << " <molWeight>" << molWeight_ << "</
molWeight>"
<< "\n</Protein>" << endl;
myfile.close();
return 0;
}