I understand jawib, but you don't know how many numbers are inputed and if they are even numbers...thats why it is not so simple, and thats why I used strtok() to go threw the input and pick out only the decimals....
I understand jawib, but you don't know how many numbers are inputed and if they are even numbers...thats why it is not so simple, and thats why I used strtok() to go threw the input and pick out only the decimals....
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
Hmmm...
Well if there is a limit to how many numbers can be entered you could do:
But I suppose it wouldn't be allowed...And its not tested anyways...I don't know I wish I could help more but I'm tired and gotta get up for school tomorrowCode:char tmp[20]={0}; //create a set cin>>command; int n; int member[100]; if( command.find("create")!=string::npos ) { n=command.find("create"); for (int i=0;(i+n)<command.length();i++) { int j=0; while (isdigit(command[i])) tmp[j++]=command[i]; member[i]=atoi(tmp); memset(tmp,0,20); } }
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
ok, this is what I did to fill up the array with the elements:
then to test if that works I wrote the print function that is also required for my program...it compiles fine but when I run it it gives me a fatal error?? any ideas?Code:void Sets::createSet( int member, SingleSet data, int &ID ) { if( data.getId() != ID ) { allSets[ID] = new SingleSet; data.setId( ID ); } allSets[ID]->push( member ); }
Code://THIS FUNCTION IS CALLED BY getCommand() from main.cpp //and it is located in class Sets void Sets::print( int set ) { allSets[set]->print(); } //above function calls this function found in class SingleSet void SingleSet::print() { for( int i=0; i<3; i++) { cout << endl << setArray[i] << " "; } }
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
>>But I suppose it wouldn't be allowed...And its not tested anyways...I don't know I wish I could help more but I'm tired and gotta get up for school tomorrow
thanks for all the advice jawib...i appreciate it. I'll work on this for another few hours and hopefully I can get it don tonite. I'll post what I have before I go to bed. The assignment is not due till friday night.
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
>>The assignment is not due till friday night
Now he tells me lol
Well good luck...
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
I don't understand one thing...why does this: int number = (allSets[ID]->setArray[0]); work int the createSet function but not afterwards in the print function????
Code:void Sets::createSet( int member, SingleSet data, int &ID ) { if( data.getId() != ID ) { allSets[ID] = new SingleSet; data.setId( ID ); } allSets[ID]->push( member ); int number = ( allSets[ID]->setArray[0] ); cout << endl << number << endl; } void Sets::print( int set ) { int number = 0; for(int i=0; i<3; i++) { number = (allSets[set]->setArray[i]); cout << endl << " " << number; } }
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
here is what vc++ debugger tells me...but I don't know how to interpret it:
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
I've figure it out...I have not been returning (&) the variables declared in main of type Sets and SingleSet.....ooops
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka