364 Posted Topics

Member Avatar for Labdabeta

That's a lot of code! What platform are you building on? I'd be happy to help dig through it, if I can match your development environment. Also, any particular reason you've implemented most/all of your methods in models.h instead of a separate models.cpp file? Have you tried running in a …

Member Avatar for raptr_dflo
0
160
Member Avatar for c_hickam

c hickam, Please start new threads for cases like this, rather than tacking onto a thread started over 6 years ago, and untouched for almost 18 months.

Member Avatar for raptr_dflo
0
100
Member Avatar for DeftArcher

[QUOTE=Cross213;1636712]Your infile >> name[i] >> midterm[i]...etc won't work because you haven't declared a struct.[/QUOTE] Declaring a struct has nothing to do with the problem. Instead, you've declared arrays that can hold 50 names, but only 5 of everything else. Then your Read_Data() function tries to read 10 entries into those …

Member Avatar for raptr_dflo
0
395
Member Avatar for Javaid1

It sounds like your issues are related more to the Arduino interface than to C++ programming. How is the digitalWrite() function supposed to behave? Is it supposed to maintain the state that you specify (LOW or HIGH)? Or is it supposed to trigger a transient switch to that state and …

Member Avatar for raptr_dflo
0
114
Member Avatar for skiboy209

skiboy209, Try consistently indenting your code. It will help you and others more clearly see what is going on. I think your errors involve where you start the nested loop (the second "do {" line), and where you ask if you want to do it again and end the nested …

Member Avatar for raptr_dflo
0
186
Member Avatar for David321

For what it's worth, the solutions here are implementations of a DepthFirstSearch algorithm, which maps well onto recursion: (approximately valid but untested) [CODE] int KeepMoving (int [][DIM] board, int start_x, int start_y) { if (NoPossibleMoves(board, start_x, start_y)) return 0; int max_moves = 0; for (int k=0; k<=7; k++) { int …

Member Avatar for raptr_dflo
0
668
Member Avatar for existinglady

And if you want the number of elements in the array to be returned, then [CODE] void InputStudents(studType Students[], int maxStudents, int& NrE) ... [/CODE] Note the addition of the '&' after int, meaning that a reference to NrE is what's passed. Also, I've included the size of the array, …

Member Avatar for raptr_dflo
0
127
Member Avatar for kambi09

Since you marked this thread solved, I imagine that means you figured out you don't need to prepend member names with the classname at, e.g., line 7 of your .cpp file. :)

Member Avatar for raptr_dflo
0
4K
Member Avatar for Clexify

Well, you need to reset i to 0 before line 12. Your code will be easier to read if you create a few simple (and well-named) functions that do specific things like: [CODE] bool isPrime(int num) { bool is_prime = True // loop to determine if num is a prime …

Member Avatar for raptr_dflo
0
333
Member Avatar for nblackburn

Since the functions and objects defined in .dlls can be used directly in a C++ program simply by linking against them, e.g. [ICODE]g++ myobj.o -o myprog -lole32[/ICODE] (or just adding the OLE library to your VS project), the notation in C++ should be much simpler. I have no actual experience …

Member Avatar for raptr_dflo
0
117
Member Avatar for jigglymig

And once your last node's Next pointer points back to Head, you have to maintain and deal with that. As far as dealing with it, your print_circle() routine will never end as currently written (current will never become NULL). As far as maintaining it, you need to address specific cases: …

Member Avatar for raptr_dflo
0
217
Member Avatar for Bench

The regulars here may well correct me (which would be awesome, btw), but first to answer your question: the point of linked lists is to make swapping elements efficient -- in particular, to swap any two nodes, you'd just swap the next and prev pointers of the nodes and their …

Member Avatar for Narue
0
3K
Member Avatar for rdhc1330

C++ is an extension to C. In addition to iostreams (and fstreams and stringstreams), it provides per-type operator-overloading and inheritable class objects. C code -is- valid C++, and an example as simple as yours doesn't need to be "converted". However, if you're learning C++, might I suggest that you start …

Member Avatar for mike_2000_17
0
826
Member Avatar for deanbrogada

We can probably help again, but it would be useful to know what your new problem is. :) As usual include (1) what you're trying to accomplish, (2) the code (or an appropriate portion of it) that you've written so far, (3) what it's doing wrong, and (4) what you've …

Member Avatar for Onlineshade
-1
189
Member Avatar for cppdeveloper

std::vectors aren't strictly needed, but they do take care of the dynamic memory allocation for you, and tend to do so in a reasonably efficient manner. I'm curious though about what your application is, that it requires several large 2-dimensional arrays, and whether it would be worthwhile or appropriate to …

Member Avatar for raptr_dflo
0
164
Member Avatar for Tim.Anderson

While it doesn't address your problem, you have a typo at line 15 (fillValue should just be a float, not a float*?), and a potential memory leak at line 48 (check whether buffer is non-NULL and if so free up the previously allocated memory before assigning a new chunk). Personally, …

Member Avatar for Tim.Anderson
0
113
Member Avatar for evilguyme

[QUOTE=evilguyme;1632173] but then does that mean for the level 2 clips i would have to declare another SDL_Rect in the class? and for the rest of the levels the same?[/QUOTE] I'm not sure. The code you've posted in your Google Doc appears to declare the SDL_Rects as global variables. Which …

Member Avatar for evilguyme
0
140
Member Avatar for matanking

I took a quick look, and as far as I can tell, your program can't get past line 33 because the only way out of your while loop is via system("exit") (which I didn't even think about until just now, and appears to kill off the CommandPrompt that your program …

Member Avatar for matanking
0
104
Member Avatar for Anuradha Mandal

You should also consider printing something besides the initial "1" if you want to see a list of numbers. If a number's ONLY prime factors are 2, 3, and/or 5, then you should be able to divide evenly by some quantity of each of those factors, and be left with …

Member Avatar for WaltP
0
137
Member Avatar for PratikM

Does the following work for you? [CODE] int main() { PlaySound("RFD",NULL,SND_FILENAME|SND_LOOP|SND_ASYNC); Sleep(10000); PlaySound(NULL, NULL, 0); return 0; } [/CODE] In the future, please try to find a minimum failing case, or feel free to trim out code that you're sure doesn't contribute to the problem. But thanks for using CODE …

Member Avatar for raptr_dflo
0
309
Member Avatar for moonray

It sounds like you're looking for basic systems engineering understanding. This is a C++ programming forum. Various people here can point you in the right direction for certain kinds of programming questions, but it sounds like you're entirely out of your league as far as the requirements of your project, …

Member Avatar for raptr_dflo
0
126
Member Avatar for dophine

I'm sure somebody will have a more definitive answer, but the basic problem with allocating small objects from the heap is the amount of overhead necessary to keep track of that object, and the extent to which the available heap memory is fragmented as small objects are allocated and freed …

Member Avatar for dophine
0
270
Member Avatar for rjcenteno

In fact, if you've gotten as far as inheritance in your class, think about what's shared across all shapes: they take a set of tokens, determine whether the tokens are valid (as Vernon started you out with), and they print out some info. As long as the specific info isn't …

Member Avatar for raptr_dflo
0
155
Member Avatar for Nelli71

Adding a function should be sufficient. Since you already have code that can step through a date-string and divide it into pieces, it should be easy for you to write a function that steps through and verifies that the pieces are the correct length and contain valid characters. Or you …

Member Avatar for Nelli71
0
163
Member Avatar for evilguyme

This time, you have defined [CODE] SDL_Rect levelOnePlatform [1]; [/CODE] but you're still calling [CODE] levelOne.set_clips(levelOnePlatform, 50); [/CODE] which is probably overwriting all kinds of other memory!

Member Avatar for evilguyme
0
121
Member Avatar for ChaseRLewis

Yuck. Not that it helps, but I've seen plenty of examples where warning 4244 is explicitly silenced in the build, rather than correcting the problem. :) Unrelated, your "load" method should probably be declared "static" as a class-method instead of an instance-method.

Member Avatar for vijayan121
0
226
Member Avatar for skorm909

As far as picking random percentage chances, try: [CODE] #include <stdlib.h> [...] double val = double(rand())/RAND_MAX; // get a random number between 0 and 1 if (val < 0.35) { // there's a 35% chance of this being true upgradesuccess = true; } [/CODE] or if you prefer percentages between …

Member Avatar for raptr_dflo
0
145
Member Avatar for massivedynamic

Try: [ICODE]g++ game.cpp -o game -Wl,-static -lpdcurses[/ICODE] or [ICODE]g++ game.cpp -o game -static-libgcc -Wl,-static -lpdcurses[/ICODE] (from [url]http://ubuntuforums.org/showthread.php?t=852552[/url] , your mileage may vary, also this requires a libpdcurses.a file which you may have to create by hand ... by extracting the individual .o files out of a .dll and re-archiving into …

Member Avatar for raptr_dflo
0
883
Member Avatar for Tauren

Hmmm... the whole premise of public-key encrpytion is that keys need to be shared, to some extent. You can still hard-code the keys you need into the sender application and the receiver application (rather than generate and exchange keys at run-time), but putting one key at each end shouldn't be …

Member Avatar for nezachem
0
143
Member Avatar for Jennifer84

If it were only that easy! You need code that can determine which computer to talk to (given a URL), open a socket connection to that computer, make a request for the contents of a specific file, read the contents over the socket connection, and write the contents into a …

Member Avatar for sergent
0
267
Member Avatar for bushh

How is this a C++ question, and what does it have to do with Facial Expression Animation? [url]http://lmgtfy.com/?q=asf+file[/url]

Member Avatar for raptr_dflo
0
60
Member Avatar for nuclear

Correct enough. SDL maintains the queue of events for you, so all you're doing is checking whether there's an event on the queue and if so, retrieving it so you can decide what to do about it. After line 7, consider adding a 'break;' statement so that you don't have …

Member Avatar for nuclear
0
285
Member Avatar for ameya1992

first google result for "outtextxy" says: [CODE] void outtextxy(int x, int y, char *textstring); [/CODE] Note the "*" character, indicating that it expects a C-style string (or Null-character-terminated array of characters) for the text to display, not a single character. Replace your first line above with: [CODE] const char* strings[] …

Member Avatar for raptr_dflo
0
1K
Member Avatar for vergil1983

Ok, so what you'll start with is some value x, and you'll write a function that computes ln(1+x) by using the formula above: [CODE] double ln_one_plus_x(double x) { double val; // insert math here return val; } [/CODE] Now you want to use exponents from 1 to 100 inclusive, so …

Member Avatar for raptr_dflo
0
215
Member Avatar for clyo cleopas

It is also generally considered "a bad thing" to use global variables, as you have declared in lines 16-19. Instead you should pass the ones you need to each function: by reference for "output" values that the function should alter, and by copy (or const reference) for "input" values. Conversely, …

Member Avatar for raptr_dflo
0
1K
Member Avatar for The Buzzer

Shaky Rox, you've posted into a three-year-old thread, in general if you have a question about an inactive thread, copy any relevant info into a new thread. Meanwhile, you can insert your own "printf()" statements if you wish to echo back what the user typed.

Member Avatar for raptr_dflo
1
137
Member Avatar for ktsangop

And there's no bigger help than inserting printf/cout statements to show you exactly which blocks of code are executing (and the values of variables too). They're easy to insert and easy to remove. If you want to get fancy you can define your own "logging system" so that you can …

Member Avatar for ktsangop
0
1K
Member Avatar for milan2011

Why do you have a Queue_head pointer (initialized to and compared against zero instead of NULL) when the comments in your header say there are just the two pointers frontPtr and backPtr? Just use those. Also, if you're going to track Size separately, then you should initialize it in your …

Member Avatar for milan2011
0
982
Member Avatar for pissman

I wrote a fairly substantial two-way socket-based communication program over a year ago. If you have a basic client-server model working (server listens for connections on a particular port, client [or multiple clients] opens socket connections to the server's port, issues a command, reads until a response returns, and then …

Member Avatar for pissman
0
308
Member Avatar for portege

And '+' is defined as the concatenation-operator for the std::string class, so [CODE] string s = "foo"; char c = 'a'; s = c + s; cout << s << endl; [/CODE] would display "afoo"

Member Avatar for raptr_dflo
0
3K
Member Avatar for nocloud

Try the following: [CODE] // return a non-cost reference std::string & access(int row, int column); // returns a const reference, second const indicates that the method // doesn't alter the grid-instance that you're accessing from const std::string & access(int row, int column) const; ... csv_File & grab(int index); const csv_File …

Member Avatar for mike_2000_17
0
202
Member Avatar for btowne2

Or, search the forum for "calculator" -- there's a recurring homework assignment on that topic, it will get you most of the way to computing the mean, and from there you can take a stab at the standard deviation.

Member Avatar for Lerner
0
192
Member Avatar for SWEngineer

Since you also posted the same question on the tutorial site you referenced above, and the author has responded, there's probably little reason to keep this thread open. Please mark it as "solved" when that's the case, and feel free to let us know what the solution was!

Member Avatar for raptr_dflo
0
269
Member Avatar for Oliverpc

There's a very suspicious "endl" being output in your center() function. Instead, I think you want to output a certain number of spaces, then the passed-in string, then another certain number of spaces, so that you've filled the width of the column.

Member Avatar for Oliverpc
0
201
Member Avatar for CPT

Heh, the last function looks great. Consider the possibility that (for some reason) you have only one valid button to draw. (Hint: the problem is actually in your Menu constructor, and has been discussed and re-discussed so many times in this forum that there's a sticky topic for it at …

Member Avatar for m4ster_r0shi
0
160
Member Avatar for sadsdw

First of all, you search for the father, then the mother, then the father again, then the mother again. It will be more efficient to search for the father first, and grab the auxID and the level at the same time; then repeat for the mother. That said, I don't …

Member Avatar for sadsdw
0
135
Member Avatar for warrior4321

[QUOTE=warrior4321;1590811]As well, I am wondering when I type in a letter, (for example, the letter h), it returns the number 51276552. Is there a way that I can restrict the user to only input a number? [/QUOTE] In your code, it doesn't "return" a large number, it actually fails (since …

Member Avatar for WaltP
0
123
Member Avatar for mchin131

You print out some of the values of the next line of the transaction file only if the current transaction number equals the current customer number. Your loop now reads a line out of the masterfile and a line out of the transactionfile, and prints one of "Transaction#..." (and some …

Member Avatar for NathanOliver
0
156
Member Avatar for PixelatedKarma

I use a really nice free color-grabber utility on Windows, so haven't bothered coding my own. I'd recommend searching for "keyboard focus" ... since you want your program to keep grabbing keyboard events even while other applications are in the foreground.

Member Avatar for m4ster_r0shi
0
212
Member Avatar for lilbluemonky

Back to your question, though, you need to implement the Polynomial constructor taking arbitrary coefficients (inserting code in your "main file" before line 17) ... the code in the following variant of the constructor (lines 20-27) is already close. You also need to implement polynomial addition in method operator+(). Finally, …

Member Avatar for raptr_dflo
0
1K

The End.