Can some one help me with this error:

=========================================error================================

In file included from /usr/include/sys/signal.h:34,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/pthread.h:22,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/sparc-sun-solaris2.6/bits/gthr-default.h:37,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/sparc-sun-solaris2.6/bits/gthr.h:98,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/sparc-sun-solaris2.6/bits/c++io.h:37,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/bits/fpos.h:44,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/iosfwd:46,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/ios:44,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/ostream:45,
from /util/gnu/lib/gcc-lib/sparc-sun-solaris2.6/3.2.2/include/c++/iostream:45,
from main.cpp:1:
/usr/include/sys/siginfo.h:259: 'ctid_t' is used as a type, but is not defined
as a type.
/usr/include/sys/siginfo.h:260: 'zoneid_t' is used as a type, but is not
defined as a type.
/usr/include/sys/siginfo.h:390: 'ctid_t' is used as a type, but is not defined
as a type.
/usr/include/sys/siginfo.h:391: 'zoneid_t' is used as a type, but is not
defined as a type.
=========================================error================================

my code works when i do everything in int main(). all i did was created a function someFunction():void and forward declarded it coz i didnt have a .h file and called it in my int main() function;

You don't need an h file if you do something like this:

void someFunction(); //prototype
int main()
{
someFunction();//call
}
void someFunction() //definition
{}

You need all three: prototype, call, and definition. If you define the function before main, then you don't need a prototype.

>>'ctid_t' is used as a type, but is not defined as a type.
This suggests there may be something else going on, too. If you have all the necessary parts of the function, then post relevant code so someone can look at it.

void createInputFileForHuffman();

int main () {
	createInputFileForHuffman();
	return 0;
}


void createInputFileForHuffman(){
	bool flag = false;
    string inFileName;
	string outputFile = "temp.txt";
	ifstream myfile;
	ofstream outfile(outputFile.c_str());

    map<string,int> mymap;

                
	//check if read file exist
	while(!flag){
	cout << "Enter the file name to read: ";
	cin >> inFileName;
	myfile.open(inFileName.c_str());

		if(!myfile){
			cout<<"File do not exist. Please try again!"<<endl;
			myfile.clear();
		}else{
			flag=true;
		}
	}

	string mainline, newline, mainLineWPun, lineWPun; 
	
	//read file
	while(!myfile.eof()){
		string line;
		getline(myfile, line);
		newline = parsingLine(line);
		lineWPun = parsingForPunctuations(line);
		mainline += " "+newline;
		mainLineWPun += " "+lineWPun; 
	}
	
	vector<string> tempVec;

	char * strMainLine = new char[mainline.size()+1];
	strcpy(strMainLine,mainline.c_str()); 
	char * splitterMainLine;
	splitterMainLine = strtok(strMainLine," ");
			
	//split the string by spaces and push into vector<string>	
	while (splitterMainLine != NULL){
		tempVec.push_back(splitterMainLine);
		splitterMainLine = strtok (NULL, " ");
  	}

	char * strWPun = new char[mainLineWPun.size()+1];
	strcpy(strWPun,mainLineWPun.c_str()); 
	char * splitterWPun;
	splitterWPun = strtok(strWPun," ");
			
	//split the string by spaces and push into vector<string>	
	while (splitterWPun != NULL){
		tempVec.push_back(splitterWPun);
		splitterWPun = strtok (NULL, " ");
  	}
	
	string spaceLine;
	spaceLine.insert(0, _totalSpaces, ' ');
	cout << "_totalSpaces" << _totalSpaces << endl;
	cout <<"space line:"<<spaceLine<<"end"<<endl;
	
	for(int x = 0 ; x < spaceLine.length() ; x++){
		tempVec.push_back(spaceLine.substr(0, 1));
	}

	cout <<"**vec**"<<endl;

	for(int i = 0 ; i < tempVec.size(); i++){
		cout << tempVec[i]<<endl;
	}
	addToMap(tempVec,mymap);
	cout <<"**map**"<<endl;

	for(itermap itd = mymap.begin() ; itd != mymap.end(); itd++){
		outfile << (*itd).first <<" "<< (*itd).second << endl;
	}

}

this is my code... assume that the functions called in the void createInputFileForHuffman(); already exists... also again the code works when I do everything i do in void createInputFileForHuffman(); in int main()


I though of explaining what this code does...


project is to read in a text file (vert big one) encode it using huffman code.

what my code posted here does is read in a file create a file by the name output.txt. this file will have a list of all the unique words, punchuations and spaces with their corosponding frequency.

eg:

//some input file
hello world this is some input file. hello! world

output.txt
hello 2
world 2
this 1
is 1
some 1
input 1
file 1
. 1
! 1
8

8 being the number of spaces.

string newline = parsingLine(line)
**this function removes all punchations from string
lineWPun = parsingForPunctuations(line);
**this function removes all characters except for punchations.

basically after that i 'm left with 2 huge strings. i split the strings by the spaces and add to a stl map. i also add spaces to the map.

after that just iterate through the map and produce the output file!

later use the output.txt file and generate the huffman encoding.


thanks

drjay

Here's one way to try to debug it. comment out the entire body of the function and compile to be sure it works blank. Then add back just one section at a time compiling after each addition. Sooner or later one of the sections will cause it to fail. Then you'll know where to focus your, and our, attention.

This article has been dead for over six months. Start a new discussion instead.