5,237 Posted Topics

Member Avatar for GirlInterrupted

> 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 …

Member Avatar for Duki
0
89
Member Avatar for megan-smith

> 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.

Member Avatar for Salem
0
126
Member Avatar for pmahalakshmi
Member Avatar for Salem
0
87
Member Avatar for csteverun
Member Avatar for csteverun
0
109
Member Avatar for hibzgums
Member Avatar for hibzgums
0
56
Member Avatar for fatihpiristine

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 …

Member Avatar for Salem
0
101
Member Avatar for BigFormat

> 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 …

Member Avatar for Salem
0
435
Member Avatar for asilter
Member Avatar for asilter
0
145
Member Avatar for zandiago

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.

Member Avatar for zandiago
0
275
Member Avatar for basimo

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

Member Avatar for Salem
0
71
Member Avatar for chubbywubba
Member Avatar for didierdrogba

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.

Member Avatar for Salem
0
720
Member Avatar for srikanth329

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).

Member Avatar for alsoumhi
0
283
Member Avatar for alsoumhi

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 …

Member Avatar for Rashakil Fol
0
106
Member Avatar for wendy2learn

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 …

Member Avatar for ShawnCplus
0
656
Member Avatar for jacques95

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.

Member Avatar for jacques95
0
144
Member Avatar for jack223

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 …

Member Avatar for vijayan121
0
192
Member Avatar for tralfas

> 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 …

Member Avatar for Salem
0
193
Member Avatar for teppuus

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] …

Member Avatar for Salem
0
132
Member Avatar for NicAuf

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 …

Member Avatar for teppuus
0
120
Member Avatar for mattarov

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, …

Member Avatar for Salem
0
83
Member Avatar for Zazabazulla

[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.

Member Avatar for Salem
0
42
Member Avatar for vn_utami

Just look at how many times sqrt() is called inside the loop. Use another variable, and save the result ONCE outside the loop.

Member Avatar for Killer_Typo
0
137
Member Avatar for Dee76

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 …

Member Avatar for Dee76
0
155
Member Avatar for -EquinoX-

What about it? Use the appropriate instruction to load a half word, and increment your address pointer by 2 rather than 4.

Member Avatar for Salem
0
235
Member Avatar for belama
Member Avatar for maverick786

If using STL is allowed, perhaps [url]http://www.sgi.com/tech/stl/next_permutation.html[/url]

Member Avatar for Salem
0
67
Member Avatar for jdphenix
Member Avatar for jdphenix
0
687
Member Avatar for annagraphicart

> 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]

Member Avatar for Ancient Dragon
0
172
Member Avatar for Metsfan147

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 …

Member Avatar for Salem
0
106
Member Avatar for JohnHull

With all the pace of continental drift, your reply to "urgent" took all of 2 YEARS.

Member Avatar for Salem
0
118
Member Avatar for kazek

> 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 …

Member Avatar for Salem
0
3K
Member Avatar for Donnovan
Member Avatar for JBI_UK

> 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.

Member Avatar for Salem
0
88
Member Avatar for bizmey

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 …

Member Avatar for Ramy Mahrous
0
118
Member Avatar for wendy2learn

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++ …

Member Avatar for Salem
0
778
Member Avatar for z_imi

<wargames>would you like to play a game</wargames> Please state your OS and compiler before continuing.

Member Avatar for Salem
0
32
Member Avatar for xerenist

Perhaps a hint [INLINECODE]for ( numNumbersPerLine = 1 ; numNumbersPerLine < 11 ; numNumbersPerLine += 2 )[/INLINECODE]

Member Avatar for Ancient Dragon
0
118
Member Avatar for wendy2learn
Member Avatar for Herm

Holland - it's the new Atlantis when global warming really begins to kick in.

Member Avatar for Lardmeister
0
241
Member Avatar for cutepoison

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.

Member Avatar for Narue
0
106
Member Avatar for navychat

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(), …

Member Avatar for Narue
0
100
Member Avatar for Brent.tc

> 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 …

Member Avatar for Narue
0
162
Member Avatar for tractionmate
Member Avatar for lasher511

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]

Member Avatar for jbennet
0
281
Member Avatar for shaqnolysis

[URL="http://www.daniweb.com/forums/post435889-4.html"]The epidemic continues...[/URL]

Member Avatar for Salem
0
55
Member Avatar for Solidsteel86

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 …

Member Avatar for Solidsteel86
1
143
Member Avatar for eranga262154

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.

Member Avatar for eranga262154
0
2K
Member Avatar for Dave Sinkula

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 …

Member Avatar for EnderX
0
331
Member Avatar for neilyan

There seems to be a rash of "do it for tomorrow" posts at the moment :icon_rolleyes:

Member Avatar for neilyan
0
170

The End.