2,045 Posted Topics

Member Avatar for lipun4u

Say you had: [code] enum priorities {zero,one,two,three}; priorities mypr; int i = 4; mypr = static_cast<priorities>(i); [/code] What does mypr then mean? There's no value in the enum for 4, so should it be cast to 4? It's saying that this behavior could cause almost any results and should be …

Member Avatar for lipun4u
0
74
Member Avatar for Jerail

[icode]#include <ctime>[/icode] and call [icode] srand((unsigned)time(0)); [/icode] (once) before you call rand().

Member Avatar for Jerail
0
424
Member Avatar for atticusr5

Either make choice a single character and acquire it by [icode] cin.get(choice);[/icode] (you will need a [icode] cin.ignore() [/icode]after to mop up the '\n' or use [icode] if(strcmp(choice,"Y") ==0) [/icode] instead of your [icode](choice == "Y")[/icode] EDIT: D'OH WaltP beat me to it

Member Avatar for atticusr5
0
88
Member Avatar for isralruval

[icode] while(!input.eof()) [/icode] See [URL="http://www.daniweb.com/forums/post155265-18.html"]this[/URL] about eof. Your function is passing in avg by reference but never doing anything with it. Either return your (S1+S2)/2 calculation and use it as such or make the function void and assign [icode] ave = (S1+S2)/2;[/icode]

Member Avatar for jonsca
0
104
Member Avatar for jdpjtp910

[quote] I am concerned on how to get the variables directly in the structure [/quote] Can you give an example (or more details) about what this means?

Member Avatar for jdpjtp910
0
515
Member Avatar for james chaco

This should be an indispensable [URL="http://en.wikipedia.org/wiki/Comparison_of_computer_shells"]reference[/URL] for you. You ought to be able to dig up code for most if not all of them (at least the *nix ones).

Member Avatar for abhimanipal
0
109
Member Avatar for ppotter3

[code] while (! input.eof()) { // Read names from file using ',' for delimiter? getline(input, Names[rTotal]); input >> Names[rTotal]; input.ignore(); ++rTotal; } [/code] This was overwriting the name you read in with the getline immediately after. You want something like: [code] rTotal = 0; while(getline(input,rTotal)) //uses default delimiter of '\n' …

Member Avatar for ppotter3
1
7K
Member Avatar for arunbarani777

You need to use DateTime.ParseExact() -- [url]http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx[/url] along with the the format specifiers on[URL="http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.aspx"] this[/URL] page. I tried to get it to work but it was fighting me on the GMT specifier. However, if you move the date to right after the month it will match the built in "R" …

Member Avatar for jonsca
0
124
Member Avatar for dchunt

Part of the problem is you are trying to read a text file in binary mode. In binary mode you need to use read() to get a block of bytes. I can see how it might read some of the chars in that way but there must be some subtlety …

Member Avatar for jonsca
0
102
Member Avatar for smarty_t2

[quote]or system("clear"); on *nix computers. [/quote] system is used to run a command of either dos or *nix on the respective system. He was offering you system("cls") on your Windows baed PC or system("clear") for use in *nix if it was applicable. However, AD was also saying that this information …

Member Avatar for VilePlecenta
0
762
Member Avatar for BobbieJean

Put in a [icode] cin.ignore(); [/icode] right before your getchar() call. There is probably something left over in the input stream after your getline call (though I think getline should discard the newline but maybe I'm thinking of something else) which is taken in by your getchar ending the first …

Member Avatar for WaltP
0
664
Member Avatar for Mono15591

It couldn't hurt to do a search at the [URL="http://social.msdn.microsoft.com/Forums/en-US/Vsexpressinstall/threads"]VS express editions install forum[/URL]. I don't know the answer to your question but they get asked this kind of thing on a daily basis.

Member Avatar for totalwar235
0
85
Member Avatar for ahaykal

[icode] getAverage(array[].4.5) [/icode] is not correct. When passing in a 2D array only the last dimension is needed, so it would be [icode] getAverage(int array[][5])[/icode] in the function definition. Make life easier on yourself and use a nested for loop approach to the averaging function: [code] for (int i = …

Member Avatar for nezachem
1
487
Member Avatar for philipbas

Start out with something like [URL="http://www.cplusplus.com/doc/tutorial/classes/"]this[/URL] (it has good examples for you). Google any terms you don't know and when you have something you're stuck on, post back.

Member Avatar for dusktreader
-2
81
Member Avatar for Roger_Hades

Change line 11 to: [icode]string get() const //get name [/icode]. I think it stems from the nature of the strings once they enter in the map (since they become keys) but I am not sure.

Member Avatar for Roger_Hades
0
161
Member Avatar for Szabi Zsoldos

You don't need to use rand/srand if you do what AD showed you. The algorithm takes care of that for itself. If you want to use the approach you propose there, just do [icode] i = rand() % QA;[/icode] (which will get you a random number between 0 and 9)and …

Member Avatar for jonsca
1
375
Member Avatar for noey699

Did you try branching off from your 3 of a kind method? [code] bool FullHouse; if (Hand.Card[4].iValue == Hand.Card[3].iValue && Hand.Card[4].iValue == Hand.Card[2].iValue) { if(Hand.Card[1].iValue == Hand.Card[5].iValue) FullHouse = true; else ThreeOfAKindCard = Hand.Card[4]; } else if (...) etc. [/code] I know it doesn't combine your pairs check with the …

Member Avatar for noey699
0
151
Member Avatar for Zay

It's got to be a static variable: [code] struct example{ static int id; float gpa; string name; }; int example::id=34440; [/code] Should be identical for the class (static variable/defined after the declaration).

Member Avatar for mrnutty
0
100
Member Avatar for ithelp

Seems to depend on which IDE you use. Visual Studio has some 3rd party tools available (see [URL="http://stackoverflow.com/questions/30947/visual-studio-08-spell-check-addin"]this [/URL]article). If you just have a text editor you can probably write a program to pare down your code to the strings (marked by a line number), import that into word, correct …

Member Avatar for Dave Sinkula
0
95
Member Avatar for C++ Beginner

The best way is to pass your struct around (you did it by reference into getInfo() which is fine) So change the prototype of getAvg to take a school & also [icode] int getAvg(school &, int total); [/icode] instead of a student (which isn't known about until you made a …

Member Avatar for C++ Beginner
0
373
Member Avatar for mmasny

Since there is no inheritance type specified, the default is private. Therefore your public and protected members become private and your private members are not accessible to your derived class. Your protected variable from A is then becoming private in B, which is then not accessible from C. I think …

Member Avatar for Fbody
0
126
Member Avatar for smarty_t2
Member Avatar for isralruval

You've omitted and mismatched. You don't even call your function. At least try to get it to compile before you post--and if after that you have a "unbeatable" error, at least let us know what it is.

Member Avatar for jonsca
0
116
Member Avatar for fiaz ranjha

Well, what do you consider to be the essential features of OOP? One hint: what kind of inheritance does C++ support vs. Java. I didn't do a net search but I'm willing to bet if you google this you'll come up with tons of "ammunition." Keep in mind that each …

Member Avatar for jonsca
0
85
Member Avatar for moroshko

Evidently you can get the number of clicks through a mousemove event (accessing them as e.Delta). see [url]http://www.pcreview.co.uk/forums/thread-1313418.php[/url]

Member Avatar for xiehuanxie
0
3K
Member Avatar for niknailer

Starting on line 84 there are some errors that,while they compile, they are not doing what you expect. 84: Where is i coming from? I see where it's declared but there's no value assigned to it anywhere and it doesn't change in the while loop 93,97: Should be == instead …

Member Avatar for jonsca
0
93
Member Avatar for dude1

NumericUpDown is a Winforms control in .NET. @OP- I tried a couple of times to get WaltP's idea (and using [URL="http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/def03dac-1602-4c46-8c76-d508150f6b46"]this[/URL] article for VB) to work but for some reason when I would try to wrap around I would get a StackOverflowException. The solution is using a DomainUpDown control (in …

Member Avatar for jonsca
0
159
Member Avatar for cin.fail

Post how you changed the code... I changed the prototype and the definition and it lets me enter the coordinates (then it does nothing so I'm not sure what to expect), but I don't get a stack overflow. Just a curiosity question: how come you didn't have solveMaze return a …

Member Avatar for jonsca
0
210
Member Avatar for Jpalka2010

Functions can go before main() as you have it, or they can go after main() but in that case you'll need a prototype before main to tell the compiler what to expect later on. In your example, for your method SearchN [icode] int SearchN(vector <string> &lastname, string searchName);[/icode] or simply …

Member Avatar for jonsca
0
166
Member Avatar for Salem

Hate to be a "Me too" but me too just now. I had also experienced the 15 second message Salem got a few days ago. I'm going to lie awake tonight staring at the ceiling wondering why me. :D

Member Avatar for Nick Evan
0
234
Member Avatar for VilePlecenta

[quote] I would drop MFC like a hot rock and learn up on WPF [/quote] A caveat to that is in order to access the managed libraries one must code in [URL="http://www.codeproject.com/KB/mcpp/cppcliintro01.aspx"]C++/CLI[/URL] which is in some cases more similar in syntax to C# and yet has its own syntactic quirks …

Member Avatar for VilePlecenta
0
330
Member Avatar for khevz09

Firstly, please use code tags (there's still time to edit your post and put them in). For your for loops, you are incrementing your values in your initialization step (and thereby skipping over the first value) and you were losing your last (if you want it) by having a termination …

Member Avatar for dusktreader
-1
107
Member Avatar for makan007

Take a look at the example on [URL="http://www.cplusplus.com/reference/clibrary/cstring/strcat/"]this[/URL] page. Is that what you are trying to do, except with digits?

Member Avatar for dusktreader
0
227
Member Avatar for atticusr5

You need to type ./a.out (or if your program is named with the -o switch) ./nameofyourprogram See [URL="http://www.unix.com/high-level-programming/7073-running-c-c-program-unix.html"]here[/URL] for an explanation that has a way around it (I'm familiar with the problem but I'm not so much a Linux guy so I don't know the dotfiles as well to advise …

Member Avatar for Salem
0
141
Member Avatar for wilsonz91

I believe it's a known problem. I don't have a solution offhand but unless you are needing 6.0 for MFC or ATL work then you should probably grab the 2008 express edition ([url]http://www.microsoft.com/express/Downloads/#2008-Visual-CPP[/url]) it does console programs, Win32, and Winforms via C++/CLI.

Member Avatar for Ancient Dragon
0
166
Member Avatar for rookanga

Did you try googling "flow charts" or "flow charting"? There are a bunch of links and most of them have the symbols. Happy hunting.

Member Avatar for wilsonz91
0
151
Member Avatar for Emerald09

Is there anything in FromInventory once you get inside of your method? I would verify it contains what you think it does and is as long as you expect. Second thing with the name is straightforward. Change your cin to a [icode] cin.getline(InputName,10);[/icode] that way it will get the spaces …

Member Avatar for jonsca
0
122
Member Avatar for gayatridevi
Member Avatar for drekha

This seems to be a popular implementation: [url]http://weblogs.asp.net/fbouma/archive/2009/05/18/multi-value-dictionary-c-source-code-net-3-5.aspx[/url]

Member Avatar for jonsca
0
57
Member Avatar for ELBUF

I just responded on your other thread. lol When you have a chance you should flag down a mod (you can hit your own flag bad post) and have them close one (or merge them, but I think closing's easier) so it doesn't get confusing.

Member Avatar for fadrior
0
658
Member Avatar for SnipeTechie

What are some of the reasons you would propose? (since clearly you're not asking this for homework or anything ;) ) Also note this is one of those questions where your professor may think there is a right answer but unless you're talking about % total of software projects in …

Member Avatar for love angel
1
296
Member Avatar for bobbuilder67

Start a new project in VC++ this time [I]uncheck[/I] precompiled headers and leave empty project unchecked. Add your files to the project by right clicking on the solution/Add.. etc. and you can clear out all the other files (or just exclude them from the project to be safe). You've probably …

Member Avatar for bobbuilder67
0
440
Member Avatar for nuB

For next time, please use the code tags [noparse] [code] //code goes here [/code] [/noparse] Count needs to be initialized to zero before the loop, otherwise you're getting whatever junk is in there upon declaration. If you want a space in your output just do [icode]outfile<<firstName<<" ";[/icode] or wherever you …

Member Avatar for nuB
0
120
Member Avatar for ELBUF

It's looking for a main() with the 2019 error. It needs some type of entry point to make the exe unless you are making a library (which I didn't read your other thread but it doesn't sound like that's what you're doing).

Member Avatar for ELBUF
0
237
Member Avatar for faaz

[code] while(x!=-999); //this semicolon ends your while right there x++; //without the semicolon only this would be part of the //while loop cout <<" enter a number (-999 to quit)"; cin >> x; [/code] Solution: [code] while(x!=-999) { x++; cout <<" enter a number (-999 to quit)"; cin >> x; …

Member Avatar for dusktreader
0
2K
Member Avatar for atticusr5

For next time, don't necessarily start up a new thread when people might still be working on that exact same issue in your old one, it gets too confusing.

Member Avatar for jonsca
0
75
Member Avatar for atticusr5

Your get_lname method is void and on 141 you are trying to compare two return values from it using strcmp. Try something like this: [code] Name_t lname; Name_t nextlname; CSCI208Class[I].get_lname(lname); CSCI208Class[I+1].get_lname(nextlname); if(strcmp(lname,nextlname)>0) [/code] or something to that effect. Or you could change the return type on get_lname() to Name_t but …

Member Avatar for atticusr5
0
119
Member Avatar for invinate

For your overloaded << operator it would have to be defined as [icode] ostream& operator<<(ostream& out, [COLOR="Green"]const [/COLOR] SparseMatrix& rhs);[/icode] otherwise the compiler is unsure whether the method will try to modify the const object or not.

Member Avatar for invinate
0
212
Member Avatar for sexyzebra19

Check out the [URL="http://gmplib.org/"]GMP[/URL] for the level of precision that you need.

Member Avatar for sexyzebra19
0
150
Member Avatar for Nexadus
Re: Lab

Just my 0.02 but it sounds like it might be a candidate for a singly linked list. You can enter the datum into it's proper place in the chain as it's coming in from the file. That approach is basically sorting the data but it doesn't explicitly take everything into …

Member Avatar for Nexadus
0
113

The End.