1,177 Posted Topics

Member Avatar for phummon

I didn't look closely, but my first thought is to try std::vector<std::string> - is there a reason you need it to be std::vector<char*> ? Dave

Member Avatar for daviddoria
0
215
Member Avatar for student9

Can you show us your readin function and then the function that is not retrieving the correct values?

Member Avatar for daviddoria
0
72
Member Avatar for philipB

Here is an example of how to use a struct: [code] #include <iostream> struct Card { int id; }; int main (int argc, char *argv[]) { Card c; c.id = 3; return 0; } [/code] It is exactly like a class, but the default member level is public. I think …

Member Avatar for Lerner
0
1K
Member Avatar for Twonk

It is very unlikely that someone is going to look through your 300 lines of code. Please whittle the code down to a ~20 line compilable example of the problem, along with sample input, expected output, and current (incorrect) output. Dave

Member Avatar for VernonDozier
0
416
Member Avatar for daviddoria

Consider these functions: [code] void OperateOnDoublePointer(double* a) { std::cout << a[0] << std::endl; } void OperateOnFloatPointer(float* a) { std::cout << a[0] << std::endl; } [/code] This works as expected: [code] double* c = new double[1]; c[0] = 3.3; OperateOnDoublePointer(c); [/code] but when I try to do this: [code] double* c …

Member Avatar for Narue
0
2K
Member Avatar for dls_20022002

To delete an element from anywhere, you'll want to use a linked list (std::list) instead of an array. Google "data structures" and you should find some overviews of when/why to use lists/maps/vectors/queues/stacks. Each has advantages and disadvantages. Hope that helps, Dave

Member Avatar for abhimanipal
0
105
Member Avatar for atmc
Re: Cpp

You need to change [code] int a[]= new a[10]; [/code] to this: [code] int* a = new int[10]; [/code] also, you have "i" as the counter variable in both the outer loop and inner loop, that is definitely going to cause problems. Dave

Member Avatar for Sodabread
-2
84
Member Avatar for brain007
Re: help

If you don't want to do your homework, why would we? Give it your best shot and someone will help you if you get stuck on a particular problem.

Member Avatar for Salem
-1
382
Member Avatar for FotG2
Member Avatar for Elenaser

In general, you should post only code relevant to the question you are asking. For example, here you basically just want to know how to read words from a file, and that has nothing to do with hangman. This is how I would do it: [code] std::ifstream fin(Filename.c_str()); if(fin == …

Member Avatar for Elenaser
0
185
Member Avatar for d34dw4rd

Can you post a bit more code (the shortest compilable example)? Personally, I anytime I see **, I think there is a better way to go. Maybe you could use an std::vector<int*> or something like that?

Member Avatar for daviddoria
0
136
Member Avatar for daviddoria

I am trying to parse the content of a wiki page. In a string like this: [code] ==Heading1== <test> some text here </test> ==Heading2== <test> even more text </test> [/code] I need to obtain "Heading1", "some text here", "Heading2" and "even more text". I got this to work: [code] import …

Member Avatar for daviddoria
0
15K
Member Avatar for mark88211

You should definitely use std::vector instead of basic arrays. No one is going to help you unless you show that you have tried yourself first. Dave

Member Avatar for mrnutty
-3
125
Member Avatar for eggberto

Please use code tags when you post code. It looks like you need to change this: [code] void myfunc(char scrpt[i]) [/code] to this: [code] void myfunc(char* scrpt) [/code] and this: [code] myfunc(scrpt); [/code] to this: [code] myfunc(&scrpt); [/code] Dave

Member Avatar for sdsda
0
169
Member Avatar for Schrödinger

So you WANT to wrap around? Or you don't? Please post your code, input, expected output, and current (incorrect) output. Dave

Member Avatar for Schrödinger
0
91
Member Avatar for sciwizeh

Is this what you're looking for? [code] #include <iostream> #include <map> int main(int argc, char *argv[]) { std::multimap <int, double> MyMap; //create a mapping from "testone" to 111 MyMap.insert(std::pair<int, double>(1, 1.2)); //create an iterator std::map<int, double>::iterator iter; iter = MyMap.find(1); if(iter == MyMap.end()) { std::cout << "Not found." << std::endl; …

Member Avatar for sciwizeh
0
110
Member Avatar for theABCasian

In SubAbstractSort.cpp, you need to change [code] void sort(int*arr, int size){ [/code] to [code] void SubAbstractSort::sort(int*arr, int size){ [/code] You also need to define the implementation in SubAbstractSort.h [code] class SubAbstractSort: public AbstractSort { public: SubAbstractSort(); int getNumComparisons(); virtual ~SubAbstractSort(); void sort(int*arr, int size); }; [/code] Hope that helps, Dave

Member Avatar for theABCasian
0
5K
Member Avatar for pok.kys90

People are not going to do your homework for you. Please figure out a concise statement of a problem you are having and you'll get a lot more help here. Dave

Member Avatar for Sky Diploma
0
235
Member Avatar for daviddoria

I am trying to strip a prefix from a string, e.g. turn [code] VTK/Examples/Test [/code] Into [code] Test [/code] Sometimes the string does not contain the prefix, in which case I would expect nothing to happen. However, [code] >>> S="Main Page" >>> S.strip("VTK/Examples/") 'Main Pag' [/code] You can see that …

Member Avatar for woooee
0
155
Member Avatar for smoothe19

It works fine for me: [code] std::string MyString = "hello,world123"; std::cout << "Original: " << MyString << std::endl; //Remove all punctuation MyString.erase( std::remove_if(MyString.begin(), MyString.end(), &ispunct), MyString.end()); std::cout << "Punctuation removed: " << MyString << std::endl; //Remove all numbers MyString.erase( std::remove_if(MyString.begin(), MyString.end(), &isdigit), MyString.end()); std::cout << "Numbers removed: " << MyString …

Member Avatar for mitrmkar
0
5K
Member Avatar for esash28

I'm not sure which grid/cells you are talking about? To your title, here is how to draw text in opengl: [code] #include <iostream> #include <cstdio> #include <string> #include <cstdlib> #include <GL/glut.h> using namespace std; void display(void); void polygon(int a, int b, int c , int d); void DrawCube(); int WindowHeight …

Member Avatar for daviddoria
0
931
Member Avatar for BobC22

On line 142 you are trying to assign something to getOwner. I don't see a variable called getOwner declared in function newg() or as a member of class ReversiGame, so that is likely where your problem lies. Dave

Member Avatar for BobC22
0
182
Member Avatar for Mz3g

You were on the right track by including sstream, but then you didn't use it! Long lists of code like this this: [code] if (IPd == ip0) { k = 0; f0.open ("Node0.txt"); f0 << "I received a packet from Node " << i << "\n"; // write all the …

Member Avatar for daviddoria
0
187
Member Avatar for Hidden_mistakes

I would suggest keeping your questions and related code as short and sweet as possible. For example, in this case, all you want to know is how to tell how long a key has been held down for, correct? Unfortunately I don't know how to do that! (sorry) Dave

Member Avatar for Hidden_mistakes
0
109
Member Avatar for Elenaser

If you want to use the enums in the other functions, they need to be global: [code] enum MAKERS {FORD,BMW,VOLVO,CHEVY,CADILLAC,HYUNDAI}; enum COLORS {RED,BROWN,BLACK,WHITE,GREY}; int main () { [/code] What are these lines supposed to do? [code] MAKERS = maker; COLORS = color; [/code] Here is a simple example of using …

Member Avatar for Elenaser
0
192
Member Avatar for Hidden_mistakes

Can you describe what you did to figure it out since you marked the thread as solved? Dave

Member Avatar for Hidden_mistakes
0
108
Member Avatar for gregarion

I would get the whole line and then split it at the spaces. This is a pretty fancy way I found, but it works: [code] #include <iostream> #include <sstream> #include <string> #include <algorithm> #include <iterator> #include <vector> int main(int argc, char *argv[]) { std::string sentence = "hello world test 1 …

Member Avatar for NathanOliver
0
143
Member Avatar for Masterslay23

You mean you want a user to login to your program? A simple string input and compare should do the trick, unless you are looking for something actually secure. You need to let us know more details about what you're trying to do. Dave

Member Avatar for daviddoria
0
51
Member Avatar for manojkv

I would do it like this: [code] std::ifstream fin(Filename.c_str()); if(fin == NULL) std::cout << "Cannot open file." << std::endl; std::vector<std::string> Lines; std::string line; while(getline(fin, line)) { Lines.push_back(line); } for(unsigned int i = 0; i < Lines.size(); i++) { std::cout << Lines[i] << std::endl; } [/code] Dave

Member Avatar for daviddoria
0
82
Member Avatar for 1manik
Member Avatar for Salem
0
118
Member Avatar for Tellalca

What command are you using to compile/link? What are the names of those files posted above? Is this the absolutely smallest code that will demonstrate your problem? Dave

Member Avatar for Tellalca
0
173
Member Avatar for Crow13

Can you please specify your problem a little bit better? Are there errors? What is the expected output vs the current output?

Member Avatar for Crow13
0
113
Member Avatar for zango

I really recommend you try to narrow the problem down to a ~ 15 line demonstration of the problem that we can look at. You should use a debugger to step through the code until you reach the line that it is crashing on - code after that is certainly …

Member Avatar for zango
0
130
Member Avatar for godflesh231

There are literally hundreds of tutorials about pointers online. I'd recommend reading as many as you can and asking here if you have specific questions. Dave

Member Avatar for K0ns3rv
0
132
Member Avatar for Derp2000

You should reply to the thread with the solution, instead of removing the question. If you delete the question, the answer doesn't help anyone in the future! Dave

Member Avatar for Derp2000
0
60
Member Avatar for Blue$kull

Since this is a c++ forum, I'll give a c++ example (I don't know anything about that extern c stuff!) main.cpp [code] #include "test.h" int main() { Test a; a.foo(); return 0; } [/code] test.h [code] #ifndef test_h #define test_h #include <iostream> class Test { public: void foo(); }; #endif …

Member Avatar for Blue$kull
0
391
Member Avatar for pinsickle

I'd recommending changing the title of your post. This isn't really that easy of a question (at least to me, haha). You should call it "Detecting splits in a btree" Dave

Member Avatar for pinsickle
0
118
Member Avatar for Nicko_FaTe_

I don't understand, if you know c++, this shouldn't be an issue at all... you pretty much just need to add some braces. Dave

Member Avatar for WaltP
0
81
Member Avatar for thehivetyrant

My suggestion is to not use OpenGL directly, but rather, use VTK! ([url]http://vtk.org/[/url]) I have been working hard for the last year writing examples, which you can find here: [url]http://www.vtk.org/Wiki/VTK/Examples[/url] There is certainly a learning curve (but there is with OpenGL, too, as you're experiencing), but it's much cleaner than …

Member Avatar for thehivetyrant
0
1K
Member Avatar for dalymiddleboro

My main comment is that I would definitely use STL vectors instead of all of your arrays - the memory is managed automatically, you can do bounds checking if you wish (with .at() ), you do not need to know/guess the size ahead of time, you can resize them, and …

Member Avatar for daviddoria
0
94
Member Avatar for dragonstar4681

Welcome to the forum. You need to close your code tag with '/code', instead of 'icode' for it to display properly. I recommend you do the following: Make as simple as an example as you can. Do not take input, but rather hard code some values. Make a 10 line …

Member Avatar for daviddoria
0
102
Member Avatar for Chetan7

I use VNL (part of VXL: [url]http://vxl.sourceforge.net/[/url]) for my math operations: Here is the function you'd want: [url]http://www.lems.brown.edu/vision/vxl_doc/html/core/vnl/html/classvnl__matrix.html#f714bb239b2b1bdbea787b5920ae07f1[/url]

Member Avatar for DavidB
0
243
Member Avatar for daviddoria

Is there a data structure that lets me push and pop things onto/off of a queue, but also doesn't allow duplicates? E.g. I want [code] queue a; a.push(1); a.push(2); a.push(2); a.push(3); [/code] to only have 3 elements, because 2 was added twice so the second time it is just ignored. …

Member Avatar for mattjbond
0
168
Member Avatar for J.Killa

You could input a string instead of an int and then check if the string contains a '.'.

Member Avatar for chary8088
0
144
Member Avatar for karthz85
Member Avatar for C++ Beginner

I'd recommend using an std::vector to store you students. You'd want to use a set of if/else if statements or a switch statement to map the numerical grades to letter grades. Dave

Member Avatar for C++ Beginner
0
81
Member Avatar for babalonas

What do you need to do with them? For image processing, I use ITK ([url]http://itk.org/[/url]) or VIL (part of VXL : [url]http://vxl.sourceforge.net/[/url]). Dave

Member Avatar for babalonas
0
121
Member Avatar for aeolusaether
Member Avatar for aeolusaether
0
249
Member Avatar for JohnPhilipps

Is this c++? I don't think [icode]ref class CSquare: Rectangle[/icode] or [icode]property int lt [/icode] are valid c++ statements. Dave

Member Avatar for jonsca
0
1K
Member Avatar for bananasplitkids

Can you post a compilable snippet? I.e. you're Event class is missing. Dave

Member Avatar for bananasplitkids
0
116

The End.