5,237 Posted Topics
Re: > So I'm taking this c++ class. It's accelerated and I started off great but now... not so much Perhaps you chose the wrong class then. Talking to your tutor would be a good idea at this stage, especially if this is early on in the course. Maybe you can … | |
Re: > but sitll, it doesn't account for invalid numbers which start with 0 or 1 ( ie 123)! Maybe put the 'if' statement inside the 'while' loop ? But separating input from conversion is good as well, as Dave has remarked. | |
Re: What have you managed to find out so far from using google? | |
Re: Your pf_spaces array doesn't have any space. Maybe pf_spaces[100]; | |
Re: Is it the same as this? [url]http://en.wikipedia.org/wiki/Big_O_notation[/url] | |
![]() | Re: Post your code and your error messages. Just because you manage to get lucky and find an old compiler which doesn't complain about your code is not an immediate sign that all is well with your code. Nor does the fact that it produces the expected results an indicator of … |
Re: > That's the very attitude that caused a mad rush to convert two digit years into four digit years Whilst memory nowadays seems to be cheap enough to be given away in cereal packets, it was not always so. Inflation and Moores law has seen to that. Back in the … | |
Re: [url]http://cboard.cprogramming.com/showthread.php?t=93997[/url] | |
Re: Perhaps output names[ i ], not names[ 120 ] You also need a loop to input them as well, you can't just read the whole lot like that. | |
Re: So what code do you have already? Break it down into two steps - code which prints the top and bottom rows - code which prints the middle rows | |
Re: Post a small and complete example program which duplicates the problem. You know, a simple class with a couple of members and a simple main to make use of it. | |
Re: So figure out how you turn "1234" into an integer on paper. "1234"(decimal) is 1234 "1234"(octal) is 668 It's just a loop of extracting the numeric value of each digit (say '3' into 3), and multiplication by the base (10, 8, 2 or whatever). | |
Re: 1. It's the caller responsibility to allocate space, then call the function with the string and the size of where to store the result. fgets() works like this. 2. The called function returns a pointer to a static string. asctime() works like this. The downside is the caller needs to … | |
Re: Say you have [INLINECODE]Rooms map[10]; // there are 10 rooms in the map[/INLINECODE] Each room has an array of neighbours [INLINECODE]enum directions { NORTH, EAST, SOUTH, WEST, MAXDIRS }; int neighbours[MAXDIRS];[/INLINECODE] Having initialised all your data, then moving north say would be simply [INLINECODE]currentRoom = map[currentRoom].neighbours[NORTH];[/INLINECODE] Valid moves would be … | |
Re: Make sure you download the full dev-c++ the first time around. IIRC, the smaller one is just the IDE by itself, which does not include the compiler. | |
Re: It's certainly poor encapsulation. Giving someone a pointer to the innards of your class exposes you to all sorts of problems. What if they try to write to your class data via the pointer? What if they increment the pointer, where does it point to then? Applying all sorts of … | |
Re: > I was wondering first if there was a clearer tutorial than then the one on the gtkmm site. How about joining the project mailing lists with the hope of getting the project documentation improved. At least there you will find the highest concentration of people who've probably succeeded in … | |
Re: Another approach to debugging is to not write so much code in the first place before trying to run it. I mean [code] do { cout << "Please enter a student indentifier from the list (or 'E' to exit): "; cin >> studentId; cout << studentId; } while (looping); [/code] … | |
Re: You might be calling srand(), but I don't see any code calling rand() as yet. Post your latest code. > It seems you have to change the srand value from srand ( time(NULL) ); > to srand (1); after rolling the die. Calling srand(time(NULL)); just ONCE at the start of … | |
Re: You're reading into the same variable that you're checking against. Also, the comma operator doesn't mean "also check". perhaps these snippets [INLINECODE]char pass[] = "pasque"; char guess[100]; cin >> guess; if ( strcmp( pass, guess ) == 0 )[/INLINECODE] > #include<iostream.h> > using namespace std; If your compiler supports namespaces, … | |
Re: [url]http://www.sgi.com/tech/stl/basic_string.html[/url] Research which member functions could be used for finding spaces and extracting sub-strings. | |
Re: Just look at how many times sqrt() is called inside the loop. Use another variable, and save the result ONCE outside the loop. | |
Re: You need to specify the max size up front. [INLINECODE]const int maxSize = 100;[/INLINECODE] Then [INLINECODE]int* a = new int[maxSize]; // Create a dynamic array[/INLINECODE] Then [INLINECODE]while((std::cin >> n) && (size < maxSize))[/INLINECODE] Though to be honest, you should really start with a [INLINECODE]std::vector<int> a(maxSize);[/INLINECODE] which takes care of all … | |
Re: What about it? Use the appropriate instruction to load a half word, and increment your address pointer by 2 rather than 4. | |
Re: Except you're 2.5 YEARS too late. | |
Re: If using STL is allowed, perhaps [url]http://www.sgi.com/tech/stl/next_permutation.html[/url] | |
Re: Your class is missing a ; at the end class foo { }[B][COLOR="Red"];[/COLOR][/B] | |
Re: > for ( int i = 0; i < 3; i++ ) > score[i]; See, that's the end of your for loop, and the end of the declaration of you i loop variable. What were you trying to achieve by just writing score[i] | |
Re: What's so weird about trying to free something you didn't malloc ? > I get the same kind of problem if I do x[3] = 'c'; or *( x + 3 ) = 'c'. Because "string constants" on your system are in read-only memory. So ANY attempt at all to … | |
Re: With all the pace of continental drift, your reply to "urgent" took all of 2 YEARS. | |
Re: > could someone please give me the full code for this program? Seriously, what would be the point of that? If you already know you're not going to make it to the end of the course, then just quit now and resume your search for a path which you can … | |
Re: I predict the next question will be why is the result always zero. | |
Re: > I want to be able to actually edit it before i build it You should first try and build it out of the box before you start tinkering with it. And make sure it runs as well. | |
Re: Apparently, the trick these days seems to be in choosing a project with the highest apparent difficulty which attracts the highest possible mark with the least amount of actual effort :icon_rolleyes: Any fool can choose a hard project which they will fail miserably at, or an easy one which will … | |
Re: I agree. Your first assumption should be that there is a bug in your code, especially if you're using widely available tools. Post some code if you're still stuck. Remember, running != bug free. > it gives me cluttered tabbing and it's annoying to fix the placement. 1. IIRC, dev-c++ … | |
Re: <wargames>would you like to play a game</wargames> Please state your OS and compiler before continuing. | |
Re: Perhaps a hint [INLINECODE]for ( numNumbersPerLine = 1 ; numNumbersPerLine < 11 ; numNumbersPerLine += 2 )[/INLINECODE] | |
Re: Holland - it's the new Atlantis when global warming really begins to kick in. | |
Re: Obviously in too much of a rush to be bothered with the simply courtesy of reading say [URL="http://www.daniweb.com/forums/announcement8-3.html"]this[/URL], or comprehending the watermark at the back of the edit window. | |
Re: Well you need to declare arrays of chars in order to read in a simple string Say [INLINECODE]char input1[100]; scanf( "%s", input1 );[/INLINECODE] The next step would be to say create a function called countVowels(), which takes a string and returns the number of vowels found. Calling this from main(), … | |
Re: > The main reason I am not using new and delete, is because 1. I tried that, and failed miserably If that is all you did, then there are hidden bugs somewhere else in your code. Simply changing [INLINECODE]char *p = new[10];[/INLINECODE] for [INLINECODE]char *p = malloc(10);[/INLINECODE] in itself should … | |
Re: The quality won't mean crap if you've made yourself deaf in the process. [url]http://news.bbc.co.uk/1/hi/health/6982184.stm[/url] | |
Re: [URL="http://www.daniweb.com/forums/post435889-4.html"]The epidemic continues...[/URL] | |
Re: Most of the statements in your if/else code lack a ; Bunching up the code like that doesn't make it any quicker, but does make it a lot harder (therefore longer) to understand. Indentation is your friend, make use of it. [code] if (sales <=30000) { com= (.2*sales); } else … | |
Re: Just read 4 bytes and don't store the result ? Or use a 'seek' function to advance the stream by 4 bytes ? A bit of code to fill us in on exactly what kind of stream you're talking about might help. | |
Re: I wonder if the native American's had the same discussion several hundred years ago? Once independent and free, now marginalised by overwhelming immigration. Strange he makes no mention of the gun, drug and "rap thuggery" cultures making their way from your side of the pond over here. The body count … | |
Re: There seems to be a rash of "do it for tomorrow" posts at the moment :icon_rolleyes: |
The End.