No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
38 Posted Topics
I have this error when debugging called Debug Assertion Failed , does anyone know what that means? Im using Visual C++ 2008. [CODE]void merge (string alpha, string beta) { string temp; string temp2; stringstream insert(alpha); stringstream insert2(beta); // Insert the string into a stream ostream_iterator<string> output(cout, " "); vector<string> words; … | |
How do you erase an element thats inside a map. Not the key but the element the key is pointing to? This doesnt seem to be doing what i want it to. [CODE]map<int, vector<int> > my_map; map<int, vector<int> >::iterator it; void erase(int num) { for(map::iterator item=my_map.begin();item != my_map.end()) { if(it … | |
I was wondering if you guys might help me figure out how to make a vector of vectors like so, The user will name the set say 'A'. And then using 'A' as a key you can then find the set name and add say 'a', 'b' to it. How … | |
I have a vector which i wish to fill with char's, so that each char is then a pointer to a vector. vector<char> list; list[0] = 'A'; list[1] = 'B'; How do I make 'A' and 'B' pointers to other vectors? [CODE] void Create_Pointers(char pointer_name) { pointer_name = new vector<char … | |
How would I find a row with a column value? Say Im looking for people with the name "Lance" then once ive found Lance display the row of info for lance. Ive tried using select but cant seem to get it to work. Here is my code. [CODE] using System; … | |
I want to find the first null child in a tree and return that node of the tree. Im thinking something like this but it doesnt seem to work the way I want. [code=cplusplus] node *Find_Empty_Node(node* root) { int index = 0; if(root) { if(root->data == 0)//<--I want this child … | |
IF i have this function... [CODE] node* get_lowest(node* root) { node* min = root->child[0]; for(int i = 0; i<root->child.size();i++) { if(min > root->child[i]) min = root->child[i]; } cout<<"Here it is:"<<min->data<<endl; return min; } [/CODE] how do I get it to return the smallest indexed pointer? for example if root->child[0] and … | |
Would someone be so kind as to help me with this insert. The function insert takes two numbers, num and num2. num is the number to insert in the tree and num2 is the number of children to the parent node where num is inserted. I am getting errors for … | |
So in a binary tree the insertion looks something like this: [CODE] void btree::insert(int num) { if(root!=NULL) { insert(num, root); } else { root=new Node; root->data=num; root->left=NULL; root->right=NULL; } } void btree::insert(int num, Node *leaf) { if(num< leaf->data) { if(leaf->left!=NULL) { insert(num, leaf->left); } else { leaf->left=new Node; leaf->left->data=num; leaf->left->left=NULL; … | |
is there a way to pass in numbers(int) like this? somename([0,0],[2,4],3); thanks for any help | |
Is it possible to input numbers into two different arrays like so, 1 2 3 4 5 6 7 8 9 where the first array would hold {1, 3, 5, 7, 9} and the second array would hold {2, 4, 6, 8}? | |
I want to enter in a bunch of integers like so: 1 11 2 12 3 13 4 14 5 56 6 80... How would I get them into an array of int? [CODE]Console.WriteLine("Enter in numbers"); string answer = Console.ReadLine(); int[] myArray = new int[answer.Length]; for (int i = 0; … | |
Trying to make a circular queue, but its not working right. Enqueue is just adding things to the end, every time. my output is: Numbers in Queue: 1 2 3 Numbers in Queue: 2 3 Numbers in Queue: 2 3 6 it should be: Numbers in Queue: 1 2 3 … | |
Im trying to make a circular queue. Why does empty keep saying my q is empty? [CODE]using System; namespace CQueue { class Program { static void Main(string[] args) { List queue = new List(); Double number = 9.13; queue.Enqueue(number); queue.Enqueue(number); queue.PrintQueue(); } } } class List { object[] thisIsQ = … | |
How would I delete one char from a string? [CODE]string aWord = "question?"; while(aWord[i]) { if(isalpha(aWord[i]))printf ("character %c is alphabetic\n",aWord[i]); else delete[i]aWord; i++; }[/CODE] | |
Does anyone know how to search a text file for just alphanumeric words using regex? And could you show me? | |
Im trying to count the frequency of words from a file and cant seem to get it to work. My frequency function recognizes the word is there but doesnt return a count for each word yet. The text file would just hold a bunch of random words...please help. [CODE]#include <string> … | |
Im having trouble turning this function into a recursion function, partly because I did it another way and now I cant think of how to do it recursively. Can you help? [CODE]int list::recursion(int item, int position) { node* temp = startPtr; while(temp != NULL) { if(temp->item == item) return position; … | |
Im having trouble seeing this recursion function through. Say I have an 8 by 8 array how would I get the search function to "see" into the middle of the 8 by 8 array. Positions (4,4), (4,5),(5,4),(5,5). [CODE] #include <iostream> using namespace std; struct matrix { int size; int row; … | |
Say you have a class called example: [CODE]class example { int one; int two; };[/CODE] and you use this to get numbers from the user: [CODE]example number; cout<<"enter numbers"<<endl; cin>>number.one>>number.two;[/CODE] and then you call one function to manipulate the numbers and another to do some more manipulation. How do you … | |
How do I insert a character into a number array? Is it possible? a and b are constants. [CODE]for(int i = 0; i <n; i++) { pointer[i] = new int[n]; } for(int i=0;i<n;i++) { for(int j=0;j<n;j++) { pointer[i][j]=1;/ pointer[a][b]="*"; //<---- } }[/CODE] | |
Is it possible to ask the user to input the size of a 2-dim array? | |
So if I have a header file like this: [CODE]template<typename T> class snake { public: void example(); private: T *start_Ptr; };[/CODE] and then a source file like this: [CODE]#include <iostream> #include <stddef.h> #include "foo.h" using namespace std; template<class T> struct node { T data; node *next; }; template<typename T> void … | |
Im having real trouble seeing this, how do I delete something out of a linked list if it is already there? My current delete function just deletes everything out of the list. the text file contains numbers like this: 75 85 95 25 35 75 85 95 25 [CODE]#include <iostream> … | |
Im just getting garbage in the output. It outputs the correct number of items but its not the right numbers. Im not sure why it is happening. The text file just has numbers like this: 12 34 56 34 67 23 64 23 [CODE]#include <iostream> #include <fstream> using namespace std; … | |
How do I get the data from file into the Insert function? Or more general how do you get data from a file and put it into a linked list? [CODE]#include <iostream> #include <fstream> using namespace std; class List { public: void Insert(); void Print(); }; struct node { int … | |
Im trying to find out if something is in this linked list function and if it is to return true and if not return false. How do you find out if ThingType thing is in the list? [CODE]bool Thelist::Search(ThingType thing) const { Node* current; current=listPtr; while(current->thing != listPtr->thing) { } … | |
Can I use getline to get two lines of string data? for example: [CODE]string line; string myfile; ifstream file; file.open(myfile.c_str()); while(!myfile.eof()) { getline(myfile, line) }[/CODE] | |
How do I input a string then output a vector from this function? The compiler doesnt seem to like "while(invector>>word)". [CODE]vector<string> example (string invector);//prototype vector<string> example(string invector) { string word; stringstream insert(invector); vector < string > vectemp; while(invector >> word) vectemp.push_back(word); for(int i = 0; i < vectemp.size(); i++) cout … | |
How do I use a pointer with a 2-dim array? I am converting string to char array. char x[25][100]; const char* A= x; A= x.c_str(); | |
My output looks like this "T h i s m y o u t p u t" and I want it to look like this "This is my output". Any suggestions? I guess what Im asking is how do you take words from a file and put it into an … | |
I know I already posted this but I guess I cant do it the way it was shown. I want a 2-dim array to print out on the same line as string word. I cant seem to figure out how to get a 2-dim array to do this, does anyone … | |
I want a 2-dim array to print out on the same line as string word. I cant seem to figure out how to get a 2-dim array to do this, does anyone know how to do this? [CODE]void Sort(string word[],float grades[][8], int number) { int i,j=o, temp; string aName; float … | |
I keep getting an error "cannot convert parameter 1 from 'char (*)[15]' to 'Student_Type *" in the swap call. gradclass is a struct and Student_Type is the name of the struct. Im trying to sort names with this. Anyone know how to fix this? [CODE=cplusplus]void SortNames(Student_Type* gradclass, int i) { … | |
I think I have a memory problem since this code keeps outputting large negative numbers. The file that it reads includes- lastname, firstname, identification number, then 5 decimal numbers. ZDoes anyone know what the problem is? [CODE]#include <iostream> #include <iomanip> #include <fstream> #include <string> using namespace std; const int rows … | |
How would I add just the columns in this 2-dimensional array? [CODE]#include <iostream> #include <fstream> #include <iomanip> using namespace std; const int rows = 5; const int cols = 5; int main () { ifstream inData; int numbers[rows][cols]; int i,j; inData.open("data.txt"); while (!inData.eof()){ for (i=0; i<rows; i++) { for (j=0; … | |
When I run this program I can only access the first row of data. Can any one help so that I can access all the lines? I am trying to store numbers into a 2-dimensional array. [icode]#include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; int main () … | |
I need some help keeping track of letters the user inputs. With my current code it only outputs one letter at a time of the word to be guessed. Can anyone help? #include <iostream> #include <fstream> #include <string> #include <iomanip> #include <time.h> using namespace std; void Hangman(); void LeftArm(); void … |
The End.