2,045 Posted Topics
Re: Try them as: [code] #include <climits> #include <cstdio> #include <cstdlib> [/code] These are the includes for use in standard C++ programs. I'm not sure what that other file is. A brief net search indicates it might be a *nix file which you will not find in the Visual Studio and … | |
Re: Your function declaration(s) (hint there) will go into your header file. So like what you have in your second code box but with a name of the function. Think over how you're going to determine which is which. You don't need to declare your variables outside of main() like that. … | |
Re: Should be [icode] HotDogStand * CartSales = new HotDogStand[numCarts]; [/icode]. Any time you are using new in C++ the return value is a pointer to that type. | |
Re: Can you post your code? (or a representative snippet from it) | |
Re: If you adjust your function's signature to: [icode]void addNames(ifstream& fin, ofstream& fout) [/icode] (the parameters used in the function body must match those in the signature) you can avoid the global variables. | |
Re: switch needs {} around the cases e.g. [code] switch(var) { case 0: do stuff; break; case 1: do stuff; break; } [/code] | |
Re: [quote]the first number after 9 that cannot be divided by 2 and 3, which would be 25 [/quote] Perhaps I'm missing something but I don't really follow the logic of this statement at all. There are a bunch that cannot be divided by 2 or 3 or both. If this … | |
Re: [quote]e.g. 3.4 to 3 [/quote] [quote]Math.Ceiling(ValueToRoundup) [/quote] Except calling Math.Ceiling() on 3.4 will give you 4.0 not 3.0. | |
Re: choice is local to the method it's declared in. However if you declare a variable choice in main (it could be called anything really I was just matching it up with your switch statement) and use it like [icode] choice = Menu(); [/icode] Then it will display the menu and … | |
Re: What I would do is use a low-tech method: read the line into a string using getline() and step through it to count the spaces. If you don't have all the numbers you need, record the line number of the bad data, throw out the string and read another line. … | |
Re: Put two slashes in front of line 1. After line 1 insert the following: [code] int main() { return 0; } [/code] I'd hold the envelope to my forehead but that's just been overdone. | |
Re: Where do you have the declaration and definition of the first code box above? You most likely need to put the declaration (top line) into your class declaration with the friend keyword in front of it. Then just include the definition in your implementation file. | |
Re: Change the name of setX to Roll. Add a statement to Roll to set the old value to another private member variable. Make a new setX that has the signature [icode] void setX(int value) [/icode] which is only used to set the value of the die if necessary. | |
Re: [quote] vc++ is not a compiler, its an IDE. Your compiler is most likely MingW. [/quote] No, Visual Studio/VC++ Express has its own compiler. If you are using an IDE such as code::blocks or Dev-C++ that comes with mingw in some cases then that will likely be your compiler. @OP … | |
Re: [quote]I keep getting "program has exited with code 0"[/quote] This is referring to value sent back via the "return 0;" at the end of main not to any result in your program. In the past (and probably still currently)people have used different error codes to signify different events causing the … | |
Re: Could your professor have meant something like disabling them as well? That was the first thing that came to my mind, but maybe that's oversimplifying it a bit. | |
Re: What have you tried coding thusfar? | |
Re: [quote]Firstly use int main [/quote] ...because it's complying with the standard and won't compile on many modern compilers [quote]there is no builtin function for two objects of //the same class to talk to each other [/quote] This is not true. It's a bit counterintuitive but objects of the same class … | |
Re: He means when you declared [icode] area_tiles [/icode] I think it might be the parens you have after t. You don't need them when declaring an object by the default constructor. Just do [icode] Tile t; [/icode] | |
Re: Try this: [code] #include <sstream> string filename; stringstream ss; cin >> filename; ss<<filename<<".dat"; outFile.open(ss.str().c_str()); [/code] The first str() gets the string from the string stream and the c_str() you already know. (fill in the name of your own output file for outFile) After further consideration I'm not sure why CP's … | |
Re: Up on line 33 initialize it to zero ([icode] int JOG_min_total = 0; [/icode]). Trace it out, the first time you're going through the loop you're getting JOG_min_total = JOG_min + (whatever garbage is in this variable at the start). So if you set it to zero you'll get the … | |
Re: This may sound like a silly question but did you try hitting ALT-Enter while it's running? I don't know much about the specifics but from what I've seen on here the later the windows version the less it's compatible with the BGI. I don't think the compiler itself will even … | |
Re: I know you said it's solved but just to clarify for you. Dividing 2 integers gives an integer result (0) which is then assigned to the double. You found the solution already. | |
Re: [noparse][code] //code goes here[/code][/noparse] (akin to an HTML tag but with [] instead) or you can highlight your code in the editing box and click on the [code] icon in the toolbar. Look at the writing on the background of the Quick Reply box. It's also in the documentation when … | |
Re: It looks ok. I'm confused as to why you are incrementing and decrementing playerTurn in the branches of the if. | |
Re: I'm assuming you're doing this for Windows? Have you had any experience with any of the GUI toolkits? I could rattle them off but there's probably a list on the site somewhere. Ok some examples anyway: MFC, .NET/Winforms (C++/CLI), Win32 API, third party ones like wxWidgets, Qt, you name it. … | |
Re: I was able to read "COMPLETE" through the following: [code] string fileline; HttpWebRequest reqFP = (HttpWebRequest) HttpWebRequest.Create("http://jamesgeddes.com/wttr.txt"); HttpWebResponse rspFP = (HttpWebResponse)reqFP.GetResponse(); Stream st = rspFP.GetResponseStream(); using (StreamReader sr = new StreamReader(st)) { fileline = sr.ReadLine(); } [/code] | |
Re: Change line 29 to: [code] if(i !=num) cout << "(" << num-i << ")" << ""; [/code] Or better you could set factorial to num in your function and change your loop to go from [icode] for(i = num-1;i>=1;i--) [/icode] and only display i. | |
Re: Variables must be declared at the top of the block. Move your declaration above the printf statement. Also, you have an extra semicolon on line 61(EDIT: Though that seems to pass through ok, I guess it's optional). | |
Re: It's a guard against including the information in the header file more than once(which can cause a mess with redeclarations etc.). You'd put the contents of your header between lines 2 and 3. At first pass if this symbol Test_h is not defined, processing goes to line 2 which defines … | |
Re: Looks like you have a space after your / and before your * -- it won't parse the comment correctly like that so it's trying to evaluate your comment as a statement. | |
Re: bookNumber is an array of char, you're trying to compare it to one single char. You can either make both of them std::string or put '1' into a char array and use strcmp. | |
Re: You don't actually return anything from Init(), make it void. | |
Re: Give this a read: [url]http://www.daniweb.com/forums/announcement8-2.html[/url] [quote]write a c program[/quote] Also, this is the C++ forum. | |
Re: Just to add one quick thing: use a while loop instead so that you can exit when you have 100 numbers not just when you've gone through the cycle 100 times (I suppose you [I]could[/I] rework your for loop to accomplish the same thing too but it might be more … | |
Re: [icode] textBox1->Lines = gcnew array<String^> {"Success"}; [/icode] is the command that you need. Buried in the MSDN entry for Lines I found the following: [code] Note: By default, the collection of lines is a [B]read-only[/B] (my emphasis added) copy of the lines in the TextBox. To get a writable collection … | |
Re: I think you just need the SuppressKeyPress member of the EventArgs, so simply placing [icode] e.SuppressKeyPress = true;[/icode] on line 3 should work. | |
I have a feature suggestion, since I know you are nothing short of super ultra busy or anything :P I use the Previous Thread / Next Thread links at the bottom of the page of posts all of the time, but I'd like to be able to do the same … | |
Re: Out of curiosity, why do you create another tic-tac-toe object within the tic-tac-toe class? To call the methods of the other class just instantiate it: [code] MyOtherClass myinstance; myinstance.methodNeeded(); [/code] (since you don't need pointers in this case you can put that on hold for a while) | |
Re: Ok. Looks like you're on the right track (you could even make ListNode a subclass of List). So now just come up with some methods for accessing the elements. A trick that might help you along is that nothing in your requirement said that this has to be a linked … | |
Re: Check out [URL="http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/129a9d68-fa73-4d7e-ae12-182f562afedc"]this thread[/URL] on MSDN. | |
Re: Once you have a new Fibonacci number use another small loop to go from the previous Fib number until the current one. Record/output those values that you find. | |
Re: You should call srand() only once and in main() before you call the methods that use rand(). What problems are you having with the output? Can you determine (using cout statements) where the data are getting lost? | |
Re: char * is a C style string (versus a std::string in C++), also a pointer to char (related to them being considered arrays of char). C strings must be null terminated (that is end in the character '\0') and they are immutable (you can't change a character while leaving the … | |
Re: For templates the declaration and implementation must be kept in the same header file (see [url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12[/url]) only a few compilers can handle the export keyword to make this possible and I don't believe VC++ is one of them. | |
Re: I don't think you really need structs for this. If you've covered arrays, strings, and string functions like strcmp and strcpy you should be all set. Rather than keeping a count with the item, keep a count in an int array (match up the indexes with those of your strings), | |
Re: Congrats on making a decent effort on what we had talked about in the other thread. [I]However:[/I] [code] array monster [level 1 , 100 health]; damage ++ 1-10; [/code] you're still making up syntax as you go. It would be the equivalent of me walking up to you to have … | |
Re: It's a typo, he meant breadth-first search. | |
Re: I got it to run fine as is on my machine: [code] Enter the first input (EOF to end): 10 Enter the next input (EOF to end): 10 Enter the next input (EOF to end): 10 Enter the next input (EOF to end): 30 Enter the next input (EOF to … |
The End.