6,741 Posted Topics
Re: Are you sure it should accept negative numbers? The bitwise operators are tricky when working with signed types. | |
Re: helloworld, are you retarded or something? Stop flooding threads. | |
Re: >the best thing to do is use visual basic, trush me is so easy Whether or not it's the best thing, the question was about C++ and posed in a C++ forum. Telling the OP to use VB is inappropriate. If he asked what language would be the best choice, … | |
![]() | Re: >lol I have yet to find a creative useful thing to use the old hardware for. Two words: battle bots. Two (or more!) desk chairs with castors, mountains of old hardware, plenty of duct tape, and a half-dozen brave interns makes for an entertaining day at work. :D |
Re: >void main is acceptable The language standard explicitly states that main must return an int. This has always been the case, except in the past the language has been imprecise enough for some to misinterpret it. Some compilers support void main, but only to cater to stupid people who don't … | |
Re: >would appreciate a practical example that is not taken from any theoretical text It's often useful to keep a reference count of how many objects are in existence at any given time. However, it's not always practical to have an object to call a member function on. Therefore, you need … | |
Re: >Public means it's accessable to the outside world, but static limits it too the segment of code where you've declared it. You're mixing up your statics. :) static is overloaded for too many different uses. In a class declaration, static means that the name belongs to the class and not … | |
Re: It depends on the context. Typically, records vary wildly. A record could be the data content in any data structure or database, or it could be a string of characters between commas in a CSV file. In the context of your previous thread, a record is a line in the … | |
Re: Do a google search for "beej". What you want to do isn't exactly trivial. | |
Re: I'm not surprised you're getting errors. Aside from the odd choice of using so many loops where one will do, you fail to close most of your blocks. Compare this with what you have and do try to learn from it: [code] #include <cstdlib> #include <fstream> #include <iostream> #include <string> … | |
Re: [code] for(c=0;c<=100;c++) { if(!(inFile>>fname)) { break; } inFile>>prin[c]>>rate[c]>>pay[c]; } [/code] That looks suspicious. If the file only consists of rows with three numbers then trying to read something into fname will eat the first and every fourth number. Try this instead: [code] for (c = 0; c < 100; c++) … | |
Re: 1) The C++ standard library consists of everything (such as the C standard library) and the STL is an obsolete term describing the container classes and iterator based template functions supported by the C++ standard library. 2) [url]www.dinkumware.com[/url] | |
Re: I don't think the C/C++ forum is the appropriate place for this question. Perhaps it's better suited to the Geek's Lounge. | |
Re: [code] #include <iostream> using namespace std; char menu() { const char *options[] = { "(e) enter invetory", "(p) purchase sode", "(s) sold soda", "(d) display inventory", "(q) quit", 0 }; char ret; for (const char **p = options; *p != 0; p++) cout<< *p <<'\n'; cout<<"Selection: "; ret = cin.get(); … | |
Re: >How can I take only the high order bit from that command? Here's a slight push in the direction of a solution: [code] #define bit(i) (1UL << (i)) [/code] You can use it to test a certain bit by ANDing the result of bit(n) with the value: [code] if ((GetKeyState(48) … | |
Re: >The best That's nice. Prove it. And anytime you say that something is the best or the worst, be ready to prove it. | |
Re: >void main() This is not, and never has been, correct C++. The C++ specification requires main to return an int. >Never ever ever use goto stmts. Normally I'd call you a moronic conformist, but you've shown yourself to be fairly knowledgeable. So I'll give you a chance to argue your … | |
Re: >typedef NutritionFacts Type; Header files don't magically know about each other. You need to tell them. For example, if node.h needs a name declared in nutritionfacts.h, you must include nutritionfacts.h [b]in[/b] node.h [B]before[/B] using the name. | |
Re: j.random_newbie@aol wants code downloads, huh? Go [url=http://www.planet-source-code.com/]here[/url] and you'll find all kinds of good (but mostly crap) "code stuff". Enjoy. | |
Re: Thank you very much. I had just managed to stop thinking about it and you reminded me. Now I hate you. :mad: | |
Re: [dripping sarcasm] Brilliant tutorial! I wonder how I've survived so many years as a programmer without reading "migthyjohn's frumph" tutorial. [/dripping sarcasm] >and i have yet to make any sense out of it Since you posted in the wrong forum, I get the impression that you don't read for comprehension … ![]() | |
Re: My first question is: why bother? Unless there's a trick that's slipped my mind, you need to copy the value into a string and then remove the first character: [code] #include <iostream> #include <sstream> using namespace std; int main() { double f = 0.123; ostringstream sout; sout<< f; string s … | |
Re: Piece 'O cake: [code] #include <cstdlib> #include <iomanip> #include <iostream> using namespace std; int main() { int n; cout<<"Height: "; if (!(cin>> n)) { cerr<<"Invalid input"<<endl; return EXIT_FAILURE; } for (int i = 0; i < n; i++) { cout<< setw(n - i - 1) << setfill('-') <<"" << setw(i … | |
Re: How do you know it's not doing something right? I'm not going to download an attached file with such an uninteresting name just to hunt down a mystery "it doesn't work" error. Be VERY specific about what your program should do, what you think it's doing, and what it's actually … | |
Re: >Do not use a loop. Smack your teacher, he's an idiot. >ask three yes or no questions and a binary search to discover the answer. Do you know how binary search works? You start in the middle and divide the range by half for each yes or no answer. For … | |
Re: Try this: [code] g++ -o sock_test sock_test.cpp -L/usr/local/lib -I/usr/local/include/Sockets [/code] | |
Re: You want help with errors yet you don't use code tags and you don't tell us what the errors are. All I get when I compile are warnings that suggest inaccurate behavior. These statements: [code] avg[i]=n+m+p/3; davg = sum/3; [/code] Should be changed to this: [code] avg[i]=n+m+p/3.0f; davg = sum/3.0f; … | |
Re: >i can't get how to get it to work Wow, that's an impressive description of your problem. I think I'll just ignore you since you were rude enough to require everyone to download attached files. | |
Re: [QUOTE=Dave Sinkula][url=http://www.daniweb.com/techtalkforums/announcement.php?f=8&announcementid=2]We only give homework help to those who show effort[/url][/QUOTE] Feh, you'd think people would be linking to one of my posts by now. ;) | |
Re: >can any one give me C program for ROUND ROBIN ALGORITHM No, do your own homework you lazy bum. >please needed urgently You should also learn not to procrastinate until the last minute. | |
Re: Using global variables makes your code harder to follow. But I immediately found this error: [code] for (int x = 1 ; x <= number_students; x++) [/code] Why are you starting with 1 and ending at number_students when the array only goes from 0 to number_students - 1? This is … | |
Re: What happens when the length of the string is less than the index you're removing from? Show me this hypothetical algorithm to it's logical conclusion. For example, remove 'e'. Then remove 's'. Then what? | |
Re: [QUOTE=chound]What are the params for find() and erase()?[/QUOTE] Some stuff with a couple of types. Google for dinkumware and do your own research. | |
![]() | Re: system returns an implementation defined value, if it returns at all. Try something along these lines instead: [code] #include <cstdlib> int main() { std::system("date /t > example.txt"); std::system("time /t >> example.txt"); } [/code] ![]() |
Re: >I read the book, but have a hard time applying it sometimes That happens at first. Programming is a very difficult activity, and anyone who tells you otherwise probably hasn't done much of it. >Programming profession or developing( is this the same as programming )? It depends on who you … | |
Re: >it automatically quarantined the viruses Good. If you're not able to detect and quarantine Netsky then your virus protection sucks. >Can I block them? Yes. >Or even crash their computers if I have to No, that's illegal. You can block a sender, but most of the time this is a … | |
Re: >yes you can asign them with =, try this Brilliant Holmes, nice memory leak you've got there. First you assign memory to a pointer, then you reseat the pointer to a string literal, thus losing a reference to the memory you just allocated. You need to figure out the difference … | |
Re: >FlushConsoleInputBuffer() is used to prevent input from echoing, correct? No. >I reposted this because it looks like my text on the other post was made too small. It looked fine to me, maybe you just reposted with an annoying font size because everyone was ignoring you. | |
Re: >i thought it was c++ was like java, where the funtions can be below main. They can be if you prototype them. | |
Re: [code] if (number % 2 == 0) // even else // odd [/code] | |
Re: >This assumes that the user has some kind of brain. You mean the hypothetical imaginary user that university professors use to avoid teaching students the reality of error checking? I've never met such a user in real life. >you have to detect the period character in the entry string with … | |
Re: Yes. To return a vector of strings, for example, you would do this: [code] vector<string> function(); [/code] To return a pointer to a vector of strings, you would do this: [code] vector<string> *function(); [/code] To return a vector of any valid type, you would do something like this: [code] template … | |
Re: Give an example of the output you're getting, preferrably at each call to insert. An initial test shows everything to work just fine, but I had to guess on the contents of list.h. | |
Re: >but how do I find the number of yards, feet and inches in the user input? [url]http://www.thetipsbank.com/convert.htm[/url] | |
Re: Okay, I guess the problem [b]wasn't[/b] painfully obvious even though I pointed it out [b]to the line![/b] You're trying to terminate your switch statement with a while condition. That's a syntax error. Change this: [code] } while (done = !true); } [/code] To this: [code] } } while (done = … | |
Re: What a display of putrid formatting! Kudos for digging your own grave by trying to be concise. Here's your program with better formatting. Notice how the error is painfully obvious now (even without my red highlighting ;)): [code] // Will Urban CS 161 2/11/05 // Assignment 2 #include <iostream> #include … | |
Re: >Be nice to people, either answer their Q's or simply dont make fun of them, please. <NOPOST> Analyzing... Dave Sinkula: 583 posts Known guru Nice and helpful Intel: 11 posts Does not seem very bright Nice and gullible Conclusion: User "Intel" tries to act smart and pretend he knows what … | |
Re: Why on God's green earth are you using K&R syntax? As for printing strings with fprintf, use %s, but make sure that the string is terminated by a null character ('\0') or you'll have issues. | |
Re: >my lecturer told me local variable is better than global hence increase data security That's an odd choice of advantages. Most people say that global variables are bad because they increase coupling between functions, make reuse harder, cause problems with multithreading, make the code harder to follow in general because … |
The End.