2,839 Posted Topics
Re: First: Learn how to use [URL="http://www.daniweb.com/forums/announcement8-3.html"]codetags [/URL]when posting code here. It makes your code easier to read. Without reviewing all of your code, I did notice one problem: [code] .... scanf("%d",&ch); { case 1: .... [/code] I suspect that you mean something like: [code] ... scanf("%d",&ch); switch(ch); { case 1: … | |
Re: Here's how to do it: [code=cplusplus] int choices[2] = {2,3}; //choose between 2 and 3 // Seed the random generator with srand() // Use rand() to pick either 0 or 1 and store in variable x int L = choices[x]; [/code] Google for srand() and rand() to find out how … | |
Re: [QUOTE=Vallnerik;994913] The reason I ask this, is because my constructor is very large and I have like 40 variables in the constructor initialization list. I'm just wondered if this is a common occurrence in games or in other large applications? Or is my class too bloated?[/QUOTE] 40 members are a … | |
Re: If your teacher taught you this, (s)he should be fired. [URL="http://www.gidnetwork.com/b-66.html"]void main[/URL] [URL="http://www.cplusplus.com/forum/articles/10515/"]clrscr[/URL] And use cin.get() instead of getch(); It's a non-standard function. Also update your Turbo compiler to something from the last 10 years by downloading [URL="http://www.codeblocks.org/downloads"]code::blocks[/URL] (free) Now for your question: There's no way to know what the … | |
Re: [QUOTE=erialclaire_238;987719]I'm having a problem on this one. using a for loop i need to make a user guess a number from 1-10 with only three tries,,, the correct number is 3 . It's running and all but it keeps showing the cout 'Your password is correct' & Program Over everytime. … | |
Re: You're not checking if your file is indeed open en ready for reading, so change this: [CODE=cplusplus]if(!fin) {[/CODE] to: [CODE=cplusplus]if(!fin.is_open() || !fin.good()) {[/CODE] Then change this: [code=cplusplus] while(!fin.eof()) { // Get the current line of the document getline(fin, programLine); // error occurrs here [/code] with this: [code=cplusplus] while(getline(fin, programLine)) { … | |
Re: I'm wondering: Why did you, again, post code without using [URL="http://www.daniweb.com/forums/misc-explaincode.html"]code-tags[/URL]? William Hemsworth specifically asked you in post #2? Also: marking your thread 'solved' when you still have a question won't get you replies. You should start a new thread with your new question. And this time use code-tags when … | |
Re: So what was wrong with using [URL="http://www.daniweb.com/forums/thread224570.html"]ShellExecute[/URL]? | |
Re: you should change [icode]filereader.readFileInformation(filename.c_str());[/icode] to: [icode]filereader.readFileInformation(filename);[/icode]. Your function expects a std::string, so no need to convert it to a char array first. Because you do that here: [icode]infile.open(filename.c_str(), ifstream::in);[/icode] Next time use [URL="http://www.daniweb.com/forums/misc-explaincode.html"]code-tags[/URL] when posting code. | |
Re: Can't explain it as good as Narue does [URL="http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_avl.aspx"]here[/URL], so you should take an hour or two to read the article. Everything will be clear afterwards :) | |
Re: How about: [CODE]std::string message = "Error "+ name + " sucks"; MessageBox(NULL,message.c_str(),"error",MB_ICONEXCLAMATION);[/CODE] | |
Re: did you seed the random-generator with srand() ? Something like: [code=cplusplus] srand(time(NULL)); cout << rand()%v.size(); [/code] | |
Re: Here's a [URL="http://www.codeguru.com/forum/archive/index.php/t-403977.html"]thread [/URL]on the conversion. Can't test it because I don't use managed code. | |
Re: Here's a [URL="http://www.cplusplus.com/doc/tutorial/files/"]tutorial[/URL]. Read it, and come back when you have questions/difficulties. | |
Re: [QUOTE=Darth Vader;993195]I am about to convert this 2D vector to managed code where I instead will use a List<String>. The problem is that I dont know how to do that, I would be happy to see how that could be done.[/quote] Short answer: you can't. Vectors and Lists are both … | |
Re: [QUOTE=calleriq;992913]Thank you everybody, I got it,[/quote] I cannot imagine that the above code would compile. One thing I spot is that you write [icode]while[/icode] with a capital W (While). That won't compile for example. Also: [URL="http://www.gidnetwork.com/b-66.html"]void main[/URL] [QUOTE=calleriq;992913]thanks god[/QUOTE] So did God give you working code then? :icon_wink: | |
Re: I have removed your empty() function because it made no sense at all. It's no different form the empty() function that a std::vector has. I also included: [icode]#include <algorithm>[/icode] because it is required for "max_element", "find" etc. I also fixed your warnings. I've put in comment what I've changed and … | |
Re: Your compiler isn't lying. You didn't delcare a, b,c or d here: [code] int main(void) { DivSales divSales; divSales.addTotal(a,b,c,d); [COLOR="Red"]// <--- here[/COLOR] [....] [/code] You should call the function with either numbers, or declare a,b,c,d: [CODE=cplusplus] int main(void) { DivSales divSales; divSales.addTotal(1,2,3,4); // with numbers divSales.printValue(); cin.get(); }[/CODE] [I]or[/I] [CODE=cplusplus] … | |
I might have an idea how to get newbies to use code-tags: Why don't you replace the (rather vague)[B] #[/B] symbol in the replybox with the word "code" or "code-tags". Some other forums I visit have this and it appears that they have a better newbie/codetag ratio :) | |
Re: [QUOTE=daviddoria;989341]I guess it was a gdb bug? I compiled the latest svn and it gets past that line now with no problems.[/QUOTE] [I]Or[/I] it's undefined behavior, which will run in 99% of the cases (for example) and crash in 1%. Show the line of code directly after the line you've … | |
Re: [QUOTE=oop'stechie;988893]well u can download it from the net[/QUOTE] You mean like the the link Salem posted in post #2? :icon_wink: | |
Re: [QUOTE=samm22;988931]HI Jason, I liked your stuff. Cool. But I think I found a simpler way : [/QUOTE] You're very close, but an even better way to do it is like this: [code=cplusplus] vector<int> vect; /* Do stuff with vect */ vector<int>::iterator iter_max = max_element(vect.begin(), vect.end()); cout << "Max is: " … | |
Re: [QUOTE=cwarn23;988614]I didn't realise that Cscgal was the one in charge of daniweb. Thanks for that information and the green light it is.[/QUOTE] So you missed: - Her title: "The Queen of DaniWeb" - Her badges: "Administrator" and "Staff writer" - And her signature saying "Dani the Computer Science Gal" as … | |
Re: I always keep a list of links that I frequently use on Daniweb. This is not the first time a useful feature is no longer linked to, although it still exists :) . Here you go: [URL="http://www.daniweb.com/forums/search.php"]http://www.daniweb.com/forums/search.php[/URL] | |
Re: You need to learn the [URL="http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx"]art of sorting[/URL]. Come back when you have tried something and have a more specific question. | |
Re: [QUOTE=minigweek;987049]Close. But still it will give wrong output. I will drop a hint. [code] for(int i=0;i<=5;i++) { //something goes in here... } cout>>i; [/code] guess what is the output of i ?[/QUOTE] I'll take a guess: Compiler error. :icon_wink: You probably meant: [icode]cout [B]<<[/B] i;[/icode] | |
Re: [QUOTE=Rashakil Fol;987109]Fail it and you're on the road to having nothing to do with your life other than moaning at people on Daniweb about their futures?[/QUOTE] So what exactly are [I]you[/I] doing here? :) | |
Re: [QUOTE=Samyx;985803]I am having a problem with my global array, it says that is not declared or something, I don't think the program is recognizing its size. How can I declare a global array without identifying its size?[/QUOTE] You should (almost) never use global variables. It's very dangerous to do so! … | |
Re: [QUOTE=Ancient Dragon;985389] I changed mine just yesterday with no problems.[/QUOTE] That's not at all how I thought you looked :) Nice dog. | |
Re: PRO: - I really like the 'edit history' functionality :) - DW is a lot faster . - the new profile page has is a lot clearer then the old one. - snippets and tuts are integrated better in the forum CONS: - I'm not sure I'm a big fan … | |
Re: [QUOTE=icu222much;985512] I then went to File --> New --> File and selected C++ File (.cpp). I then saw a blank screen for me to type my code so I entered in my Hello World program. I went to Build --> Build Solution and again I have the same error.[/QUOTE] It's … | |
Re: You really aren't the sharpest knife in the shed are you? Why don't you listen to good advice [URL="http://www.daniweb.com/forums/post960283-5.html"]when someone gives it to you[/URL]? | |
Re: If you find this insulting: [QUOTE=javaAddict;966439]The only bug I see is you accusing a programming language which has been around for decades, used by thousands, for your incompetence.[/QUOTE] Then you should be lucky you didn't ran into me in the C++-forum :icon_twisted: My advice would be to grow up. Whining … | |
Re: [QUOTE=marco93;985632]... and [B]wrong [/B]code ...[/QUOTE] Why? For once, tell us [I]why [/I]you think this code is wrong instead of leaving a piece of sh*t comment and then run and hide when you get a reply. | |
Re: I think you mean: [icode]double out = atof(in.[B]c_str()[/B])[/icode] instead of [icode]double out = atof(in.data())[/icode] | |
Re: [QUOTE=xfreebornx;985764]please can u write it in a sample program for me because i don't understand what u meant......[/QUOTE] Yes I could. But the real question is: what don't you understand from what Ancient Dragon told you? What have you tried? Show some code and tell us what the problem is. … | |
Re: [QUOTE=William Hemsworth;984316]Donate :)[/QUOTE] [I]Or[/I] be a member since the time that animated-avatars were still allowed and never change it, like I did. (yes it [I]is[/I] animated) :) | |
Re: Don't know if it's a bug or not, but I'm allowed to edit tags on threads. I don't even know what it does, but it looks like something only mods are allowed to do :) | |
Re: [QUOTE=MattyRobot;982595] the code I wrote I had included all the things you mentioned and still didn’t work. the function had a prototype and the class had a semicolon. but the compiler said that the function was not declared in the scope. [/QUOTE] You could also post the [I]actual[/I] code here, … | |
Re: [QUOTE=Tom Gunn;982618]It only sounds easy because we have learned by making the same mistakes before. I still mistype counters all the time, so I know how to find it and prevent it. ;)[/QUOTE] Exactly. One of the other typos I still make now and then is : [icode]if (a[COLOR="red"]=[/COLOR]1)[/icode] versus … | |
Re: What have you done so far? Here's tutorial on [URL="http://www.cprogramming.com/tutorial/lesson5.html"]switch statements[/URL]. Read it and try to start for yourself. Then come back with a specific question. | |
Re: You mean something like: [code=c] unsigned char a = '0'; unsigned int b =a; [/code] 'b' will now be 48. That's the [URL="http://asciitable.com/"]ASCII[/URL]-value of '0' (zero) | |
Re: [QUOTE=ithelp;980334]That code will not compile[/QUOTE] First : DdoubleD was pointing out a flaw, he wasn't giving a suggestion. Second: Why wouldn't this compile? | |
Re: You should change: [code] #include "cv.h" #include "highgui.h" [/code] to: [code] #include <cv.h> #include <highgui.h"> [/code] also check manually if the file [icode]C:\Program Files\OpenCV\bin\highgui110.dll[/icode] exists. If it does: re-install openCV Next time you post: use [URL="http://www.daniweb.com/forums/misc-explaincode.html"]code-tags[/URL]. Also bumping your thread is considered very rude and you're lucky I'm in a … | |
Re: [QUOTE=Behi Jon;980208] For example, look at this codes : [..code..] What it say ?[/QUOTE] It declares an int-array and loads it with values. The array is const static which means that the values in the array cannot be changed. The second line of code declares a static unsigned char array … | |
Re: [QUOTE=Behi Jon;980221]I don't want the code; Just a guidance like this : [B]You can use recursive functions[/B][/QUOTE] Ok. --> [B]You can use recursive functions[/B] Also: Loops. | |
Re: [QUOTE=networkmancer;979480]And sorry but IM ******** New to C++. And its compiler btw is Turbo C++. Its ancient. Thank you. Please stick to the topic. Im new to C++ and knows nothing.[/QUOTE] So you think bashing on a respectable regular is going to help you with your question? I don't think … | |
Re: You're using try and catch, so that's a good thing. How and where you throw and catch is also a matter of personal taste. Some people (like me) try a small piece of code and catch if something goes wrong. Some other people just wack their code in one big … | |
Re: [QUOTE]Goolge Draws Ire of Privacy Advocates -- Part I [/QUOTE] Goolge?? The rest was good reading! regards Niek |
The End.