1,362 Posted Topics

Member Avatar for Voltron160

First I would ask, "WHY?" Why take the slowest sort and slow it down further with the overhead of more function calls and additional memory usage? And, you will have a sort that may overflow the stack on sorting a large array. That said, a quick bit of googling finds …

Member Avatar for LevyDee
0
1K
Member Avatar for cypherinfo

I'm not fully sure what you're looking for. If you browse in Windows Explorer to the folder where the program you want to run is located, shift+right-click and choose Open Command Window Here. You then are in a command window at that folder. If you want to be able to …

Member Avatar for cypherinfo
0
2K
Member Avatar for blind122

So just what is that you're trying to do with this statement [icode]string letter= str.length(i, 1);[/icode]? Once you fix that, then there's issue that your function is not being used in main( ). (yeah, what Auto said!)

Member Avatar for blind122
0
128
Member Avatar for vmanes

[URL="http://www.metal-club.org/ElectricLesson.html"]What in the world is electricity and where does it go after it leaves the motor in your lathe or mill? [/URL]

Member Avatar for vmanes
0
78
Member Avatar for apegram

Doing a good job is like peeing your pants in a dark suit. It gives you a warm feeling, but nobody notices.

Member Avatar for geekgoddess
1
242
Member Avatar for yapkm01

[QUOTE=jonsca;1160338] ch1 is a char so it holds 1 character. When you are typing in the character to go into this variable, you hit enter. Enter is a character which remains in the input stream and is processed by the [iCODE] cin >>int1;[/iCODE] call which interprets it as "someone has …

Member Avatar for vmanes
0
113
Member Avatar for corisco7444

Well, is there another computer on your network? Do you set fixed IP addresses, or let DHCP on a router handle them? More info needed to give any definitive help.

Member Avatar for vmanes
0
46
Member Avatar for dreamstone

There are a few approaches one can take. Get input. Check the state of the input stream, if it's good, you got an integer. If it's bad, you didn't, so you need to clear the error state and flush out all that remains on the input stream and try again. …

Member Avatar for vmanes
0
94
Member Avatar for lgonzo

How about you tell us what you think the answers are, and why the other choices are not correct, and we'll help you to understand any that you got wrong.

Member Avatar for vmanes
0
304
Member Avatar for cwarn23

[QUOTE=apegram;1156383]The comma seperates the negative! That's my story and I'm sticking to it.[/QUOTE] As well you should. AD - this is from Tongue and Quill, on commas:[quote] b. After introductory words such as yes, no, or oh. Yes, I’ll do it. Oh, I see your point[/quote] In a related vein, …

Member Avatar for Biker920
0
139
Member Avatar for clutchkiller

I'd been thinking of asking the question about the HW ad myself, just never got around to it. Really bugs me as I use them, have two sites hosted there. And after a brief respite, IT'S BAAAAACK!!

Member Avatar for cwarn23
1
130
Member Avatar for hurricane123

Yes, you can write a C++ program to do all that. Oh, I mean YOU can write it, we won't. Please read the sticky threads explaining how to get help here.

Member Avatar for hurricane123
0
126
Member Avatar for aatwo

You could store the data as a separate file, then the code to read and store the data to your array of structs is quite small and simple. Your last example is almost correct in line 1 for initializing the array, but you must indicate that it's an array [code] …

Member Avatar for aatwo
0
139
Member Avatar for theforgotten
Member Avatar for theforgotten
0
139
Member Avatar for Jaxzen

You need to move the [icode]using namespace std;[/icode] line to be above the function prototype.

Member Avatar for vmanes
0
153
Member Avatar for aceofspades451

If your primeNum is a factor of the array size, you'll keep displaying the same values again and again as you go around the circle, skipping over most of the data.

Member Avatar for aceofspades451
0
152
Member Avatar for richman0829

Works for me. Doublecheck the spelling of your data file name, does it agree with what's in the code? Is the file in fact where your program is expecting it to be? What environment are you using, how are you executing the program?

Member Avatar for richman0829
0
159
Member Avatar for 'AnKo

[code] while(newfile[when]) when++; //gets "newfiles" length [/code] Does not do what you think you want it to. It stops at the first char with value 0, which might be a value in the date that occurs before the end the input file, but is not guaranteed to mark the end …

Member Avatar for 'AnKo
0
324
Member Avatar for GrimJack
Member Avatar for JTX

How would assign a value to an element of the array? Pretty much the same you assign a value to a plain int. Your loop is fine, if you know exactly how many values are in the data file, and that number is the size of the array. Usually a …

Member Avatar for JTX
0
142
Member Avatar for spikeru

don't put the [] on the parameter in the function header, just the ** [code] //not double** transf[][] ) //just double** transf ) [/code] What you're describing is a two-D array of 2-D arrays!

Member Avatar for vmanes
0
1K
Member Avatar for dnalor

For starters, what is this suppoed to be doing in function menu() [icode] return choice = main();[/icode]?? Just return the value choice. It would help if you gave a better description of the error that occurs, but I'm betting you get a debugging message about your array [icode]fgrade[][/icode]. Your function: …

Member Avatar for brillantes
0
87
Member Avatar for axed

[QUOTE=axed;1145560]Hi, I want to know when and where is memory allocated for static variables. If: 1) static variable is in a function 2) static variable is a member of a class 3) a global static variable inside a file of code. Much appreciated. Google hasn't been much of a friend …

Member Avatar for axed
0
159
Member Avatar for atticusr5

The program is halting at this line: [code] void Insert( List_t &List, Addr_t &Start, Addr_t Pred, Addr_t &Avail,cAccount NewAccount) { Addr_t Curr; Curr=Avail; Avail=Avail+1; List[Curr].Account=NewAccount; ///breaks here [/code] And is doing so on the very first record (John Walker) You also have many warnings that you should attend to, such …

Member Avatar for atticusr5
0
180
Member Avatar for gizgiz

Now I might be wrong about this, but I think your char* in main is pointing to where the literal string is in the code. It is not allocating space on the stack for a variable. Your function is then attempting to change the code, which it's not allowed to. …

Member Avatar for gizgiz
0
139
Member Avatar for jonyb222

You're trying to assign NULL to a Train object, or to compare NULL to a Train object. You haven't overloaded the = and == operators, and it wouldn't make sense to assign or compare NULL in any case. ar is the pointer - that can be assigned or compared to …

Member Avatar for jonyb222
0
3K
Member Avatar for Allyw

What do I like most in Win7? That it's not as annoying as Vista. I'm still annoyed that Create a Restore Point and doing a System Restore are separate apps.

Member Avatar for BestJewSinceJC
0
404
Member Avatar for nanosani

The poll is actually to restrictive for me - different machines get different treatment. Office PC is left locked when I'm not around. Main home machine is on 24/7. Laptops I hibernate when not in use. A few other desktops around the house get hibernated till needed. What is this …

Member Avatar for altuin
0
166
Member Avatar for corby

One reason to compare pointers is to compare two pointers for equality (or inequality) to determine if they are pointing to the same thing, or not. Or if a pointer is pointing to anything at all (ie. ptr != NULL ). Otherwise, using > or < comparison, it's kind of …

Member Avatar for Dave Sinkula
0
179
Member Avatar for eternaloptimist

[icode]cout << setw( 20) << "Find Allen, Jim: ";[/icode] use whatever number of spaces will contain your longest string. Remember that setw is not a sticky setting.

Member Avatar for vmanes
0
251
Member Avatar for frag

It has no indentation? It's using old, outdated include files? It has meaningless variable names? Oh, and the % symbol is used incorrectly. You really should explain your problem. What should it do, what it's actually doing, where you think the problem might be. If your compiler generated any error …

Member Avatar for vmanes
0
94
Member Avatar for nike_jj4

You could use any of the regular sort functions. Your comparison must be correctly done, as in [code] if( strcmp( my_class[i].lastname, my_class[i+1].lastname) > 0 ) [/code] which is the comparison for bad ol' bubble sort. I changed the array name as "class" is a reserved word. And you have an …

Member Avatar for WaltP
0
107
Member Avatar for karolik

You could allocate an array of 1 to 100, then shuffle it. Or, as you generate a new number, scan the current array content looking for duplicate, reject the number if found. But that becomes a time consuming operation, the more full the array gets. I'd go with the first …

Member Avatar for jonsca
0
118
Member Avatar for wwsoft

Yes, you could use sort( ), provided you provide a comparison function.

Member Avatar for mitrmkar
0
104
Member Avatar for angel6969

I think this function[code] void Point::shift(double dx, double dy) [/code] shoudl add dx to the x member and add dy to the y member. As to errors, please post the exact error message (or pertinent parts thereof) and where in your code you think the problem lies. When posting code, …

Member Avatar for vmanes
0
98
Member Avatar for bori02082009

divide, then use modulus. You can create a loop, where the value you divide by is decreasing power of 10

Member Avatar for abdelhakeem
0
166
Member Avatar for fugnut

First of all, to enter and process the user's conversion choice, [icode]sym[/icode] must be of type char. Then, in your switch, you don't need the if statements - the switch does that. [code] switch ( sym ) { case 'c': case 'C': //do the Celsius conversion break; case 'f': case …

Member Avatar for fugnut
0
177
Member Avatar for react05

Compiled in VC++ 2008. Runs fine from the IDE and directly from the command window, or double clicking program file. Want to give more details on what you did/tried and the system description?

Member Avatar for vmanes
0
54
Member Avatar for casjackkwok2001

[QUOTE=firstPerson;1132075]Your sort array needs another for loop.[/QUOTE] No it doesn't. The do...while is the outer loop, continues until a pass of the inner for loop goes without any swap occurring. However, it is less efficient than it could be, as it keeps comparing at the far end of the array, …

Member Avatar for vmanes
0
262
Member Avatar for AmigaCarolena

cin statements put input into the variables you declared. The actual values, Bronco, 2005, 12345, etc will be entered during runtime in response to the program's prompts.

Member Avatar for gnarlyskim
0
337
Member Avatar for mebob

Big, and I mean BIG, problem is first of all that you are using type float - which is not very precise in dealing with large numbers. And your numbers get really, really large. What happens in this: [icode] fac( 6 * k ) [/icode]. At the limit of your …

Member Avatar for vmanes
0
440
Member Avatar for jigglymig1

Your counting of letter occurrence looks to be correct, but could be more efficient. Back to that in a bit. This:[code] if(numberOfTimes[i] > numberOfTimes[i-1]) { max=i; } [/code] should be in a separate loop, after all the letter counting is done. Once you have the counts of letters, then scan …

Member Avatar for r.stiltskin
0
161
Member Avatar for ccie007

As with any non-trivial problem, get out pencil and paper and start breaking the problem into smaller sub sections. Keep refining till you are at least at the level of describing each function you need - what goes in, what it does, what comes out. This one has a few …

Member Avatar for jonsca
0
211
Member Avatar for PDB1982

I think you're on the right track [code] for(i=0;i < numStudents ;i++) { tmp=array[i]; for(int j=0;j<numStudents;j++) { if(array[j]==tmp && (j>i)) { cout << array[j] << endl; } } } [/code] You examine each element of the array, and compare it to all others, looking for a match. Your j>i test …

Member Avatar for jonsca
0
198
Member Avatar for tudorH

That sort of statement will only work at array declaration. [code] int data[][3] = { {1,2,3}, {4,5,6} }; [/code] In your case, where the array is declared in the header, it must be given a size for both dimensions. Then, in the constructor, you must initialize it within loop(s). [code] …

Member Avatar for vmanes
0
172
Member Avatar for Mushy-pea

[QUOTE=vegaseat;1119398]Wealth created by speculation can evaporate quickly. The US government owns a huge amount of land and resources that it can use as a collateral.[/QUOTE] But the greenies have it all tied up with restrictions so nothing useful can be done with it. What's it really worth?

Member Avatar for jbennet
0
287
Member Avatar for bbabarajj

If you're writing a C++ statement like that, the answer should be 1. 1/1 = 1 1/2 = 0 1/3 = 0 ..... Please show the actual code, and we can give an actual help.

Member Avatar for bbabarajj
0
2K
Member Avatar for invisi

This bit bothers me [code] if (num > 10) {quit = true;} cout << factorial(num); [/code] Is it your intent not to find factorial of 10 or greater? And to use the 10 or greater input as a quit signal? The way you have it, your code will set up …

Member Avatar for vmanes
0
75
Member Avatar for Anarionist

[icode]if(name==s[0-4])[/icode] says to compare name to s[-4], which is way out of the array's bounds. You will have to construct a loop and compare name to each string in array s, one at a time.

Member Avatar for dusktreader
0
141
Member Avatar for ELBUF

OK, back up the train a bit. [icode]int num_players(0);[/icode] is not the way to initialize a simple data type. Try: [code] int num_players = 0; [/code] The array of player structs needs be only a 1D array, so your [icode]**playersp[/icode] is excess. The input function prototype ought to be more …

Member Avatar for vmanes
0
137

The End.