6,741 Posted Topics
Re: >like a one-chance sort of thing where you're in probationary status, repeat offense would be irrevocable? Infractions already expire. Though in some cases we apply a permanent ban after the second chance. | |
Re: [QUOTE=siddhant3s]Promise me that you/ your students will not ask questions like these in forums like these.[/QUOTE] You should be ashamed of yourself, and your attitude disgusts me. [QUOTE=siddhant3s]For the beginners of C++, The standards should be treated as Laws. For experienced programmers, these things will eventually clear up as you … | |
Re: >For example, 2^3^4 should be evaluated as 2^(3^4). >So I should get 2^81, instead of the usual 2^12. Erm, it looks to me like the input is supposed to be prefix rather than infix. If you're getting 2^12 for your result, then I suspect you aren't entering the correct expression. … | |
Re: [code=cplusplus] #include <iostream> #include <string> class Foo { public: Foo() { throw std::string ( "poop" ); } }; int main() try { Foo f; } catch ( const std::string& msg ) { std::cerr<< msg <<'\n'; } [/code] | |
Re: >So to understand these codes detail what kind of books i have to read and tutorial i have to learn. Why don't you just read the documentation on MSDN? It's all there. >strcat(system,”\\virus.exe”); *sigh* | |
Re: [QUOTE=tux4life;855287]If a function doesn't require any arguments in C you have to put the [ICODE]void[/ICODE] keyword between the function's '(' and ')' brackets (if you really want to be correct :P), like this: [ICODE]int main(void)[/ICODE][/quote] You don't have to, but it's a good idea for the sake of consistency and … | |
Re: >std::transform(msg.begin(), msg.end(), msg.begin(), std::tolower); Congratulations, you've propagated one of the more annoying bugs among C++ help forums[1]. 1) tolower isn't just a function in <cctype>, it's also a template in <locale>, which is allowed to be included by any standard header (<iostream> is the usual culprit). As written, there's an … | |
Re: Post your code and trim it down to the smallest parts that can be compiled. I'd guess that you're missing something, like a definition for the function or you're not linking the files correctly. | |
Re: >Also I have googled for "windows form application in c++" and very little has comeup! Really. None of the 35 million hits was even close to relevant? I find that hard to believe, especially when the first page looks both relevant and useful. >How can I do this? Handle the … | |
Re: >Without No Reason Damn straight. There's always a reason, even if it's not immediately obvious to you. >when i started using variable block sizes it crashes Then your first task should be verifying that you're reading from/writing to memory that you own. I'd wager that your problem is an out … | |
Re: >And learn VB.NET, VB6 is dead. VB6 is dead like COBOL is dead. It's not the latest and greatest, but you can make a damn good living with it. ;) | |
Re: You can only switch on integer values. This restriction makes more sense when you think of a switch statement as a table lookup where each case is an index into the table. >switch (choice[0], choice[1], choice[2], choice[3], choice[4]) >and that didn't give me a compiler error, but would this be … | |
Re: >i have no clues on how to begin this Then either you weren't paying attention in class (if you're a student) or you're woefully unqualified for your job (if your a professional). I'm especially unsympathetic to people who claim not to have a clue and then ask me to do … | |
Re: >I don't know exactly why it's needed either. There's the potential for a parsing ambiguity when you use dependent names[1]. Let's look at an example: [code=cplusplus] template <typename T> void meep() { T::Baz *p; } [/code] Clearly this code is intended to create a pointer to T::Baz and T::Baz is … | |
Re: >It's only been two days I wouldn't call that a statistically significant sample then. It could just have been a heavy two days for new registrations. :icon_rolleyes: | |
Re: The declaration syntax is probably the biggest wart C++ has. Here are a few tricks for figuring out what a declaration means, or how to write one: [LIST=1] [*]Simple declarations can be read backward to get the real meaning: [ICODE]int *p;[/ICODE]: p is a pointer to int [ICODE]int **p;[/ICODE]: p … | |
Re: It looks to me like you took three different solutions you found on the web and mashed them together into one hideous mess. Compare and contrast: [code=cplusplus] #include <iostream> int main() { char ch; while ( std::cin.get ( ch ) && ch != '\n' ) { if ( 'a' <= … | |
Re: >It doesn't seem to me that creating this would cause a segfault... Just because it dies there doesn't mean the problem occurs there. Don't confuse the symptom for the cause and you'll understand why memory errors are among the more insidious bugs you can encounter. Sadly, you haven't provided enough … | |
Re: [ICODE]clog.rdbuf(clog.rdbuf());[/ICODE] doesn't do anything meaningful. You've already replaced the stream buffer, so the original one is gone unless you save it elsewhere: [code=cplusplus] ofstream ofs("file.log"); // Save the original stream buffer streambuf *clog_save = clog.rdbuf(); clog.rdbuf(ofs.rdbuf()); clog << "Logged." << endl; ofs.close(); // Restore the stream buffer clog.rdbuf ( clog_save … | |
Re: all_nodes is an empty vector, merge is trying to access indices that don't exist. If you want all_nodes to be populated by std::merge, you can do it with a back_inserter: [code=cplusplus] #include <iterator> merge(from.begin(), from.end(), to.begin(), to.end(), back_inserter(all_nodes)); [/code] Alternatively you can resize all_nodes so that you no longer overrun … | |
Re: This is a risky venture because people expect array notation to have random access performance characteristics. Linked lists are not random access, and simulating random access is not only relatively expensive, it becomes more expensive as the list grows and the subscripts get larger: [code=cplusplus] Polynomial& Database::operator[] ( int i … | |
Re: I match several, depending on my mood and whom you ask: [URL="http://redwing.hutman.net/~mreed/warriorshtm/bigdogmetoo.htm"]Big Dog[/URL] is probably my closest match. I even have several Me-Toos, but I won't name them. Occasionally I feel like [URL="http://redwing.hutman.net/~mreed/warriorshtm/godfather.htm"]Godfather[/URL], but I jump into the fray too often for it to be a good match. And of … | |
Re: >Watch this thread get deleted... just like my tutorials. Wow, you're not bitter about it at all, are you? :icon_rolleyes: It's nothing personal, so don't take it personally. Acting all whiney and childish doesn't help your cause, unless your cause is to destroy your own reputation. | |
Re: Why? This is a suspicious activity, so we need a good reason before helping you with it. | |
Re: >except one thing needs a bit stronger emphasis. >never, ever use "GOTO" this is not BASIC programming. Note to the OP: Avoid listening to programming advice that says you absolutely must or must not do something. | |
Re: >Nobody help this lazy @$$ clown. We wouldn't have anyway. Cheaters and leeches are quickly shunned from the community. p.s. You don't need to trick the censor, "ass" is perfectly acceptable here. | |
Re: You have to do that work yourself now, because you've sidestepped the shell and taken over its job. Now it's your job: [code=cplusplus] #include <iostream> #include <string> #include <conio.h> std::string get_password() { std::string password; int ch; while ( ( ch = getch() ) != '\r' ) { if ( ch … | |
Re: If the replacement text is exactly the same length as the text being replaced, you can search the file and then overwrite what you need when you find it. Otherwise, you're probably stuck with the temporary file approach. Alternatively, you can keep the records in memory and edit them to … | |
Re: >Plz provide me complete discription of four algorithms used for sorting arrays e.g bubble sort. How about you tell us what you came up with first, because this is clearly homework. >Four bad sorts: Okay. >bubble sort Works for me. >insertion sort Insertion sort is not a bad sort. It's … | |
Re: >Coders will have your head for not using argc and argv. xD Nah, but the hungarian notation will start wars. ;) | |
Re: >le sigh. :D It seems you've suffered enough for that bit of code, so I'll restrain myself. | |
Re: Try this and see if you get more information: [code=cplusplus] #include <cstdio> #include <fstream> #include <string> #include <iostream> using namespace std; int main() { string filename; cout<<"Please type the name of the file"; cin>>filename; fstream file(filename.c_str()); cout<<filename.c_str(); if (!file) { perror("file could not be opened"); exit(1); } //... } [/code] | |
Re: >why does the above code work? Because there are only two things you can do with a function: take its address and call it. If you're not doing one, you're doing the other, and C basically ignores redundant levels of indirection on a function. This will work too: [code=c] #include … | |
Re: >This wouldn't be a problem for me in C, but i want to do it in C++ You can use a C solution in C++, you know. But that aside, just read each line and don't do anything if the first non-whitespace character is '#': [code] #include <fstream> #include <iostream> … | |
Re: >Error C208 DS1302GetAll Too many actual parameters This is how you are declaring DS1302GetAll: [code=c] void DS1302GetAll(SYSTEMTIME *Time); [/code] This is how you are calling it: [code=c] DS1302GetAll(Second, Minute, Hour, Date, Month, Week, Year); [/code] I'd say your error is quite right in saying that you're passing too many actual … | |
Re: What have you tried? Staring at your keyboard with a dumbfounded expression is unproductive, and I suspect that your teacher wouldn't have given you this assignment without providing any prerequisite information. Here's a start: [code=cplusplus] #include <iostream> int main() { int num; while ( std::cin>> num ) std::cout<< num <<'\n'; … | |
Re: This is the original code, right? [code=c] char *cTempPtr = NULL, search[256] = "init"; cTempPtr = argv[1]; strcpy(search, cTempPtr); [/code] The equivalent of that without using cTempPtr is as follows: [code=c] char search[256] = "init"; strcpy(search, argv[1]); [/code] There's no magic involved between assigning cTempPtr and using it in strcpy, … | |
Re: I don't think your question will get an answer seeing as how karen_CSE hasn't been active since 2006. | |
Re: >cout<<fly.freeSeat; freeSeat is a function. Even if there are no arguments, you still need the (empty) parameter list: [code=cplusplus] cout<< fly.freeSeat() <<'\n'; [/code] | |
Re: I highly recommend formatting your tree in a text editor set to a monospace font. I'm assuming this is the tree you wanted: [code] A / \ B C / \ / D E F / \ G H [/code] Normally when people ask "is this right" questions, I reply … | |
Re: The answer to your question is no, because the #include directive is run at compilation time. It's long done by the time you run your program at all, much less on another machine. To change the path in the directive, you'd have to recompile. Usually a relative path is sufficient: … | |
Re: [psychic debugging] You're probably forgetting to initialize one of your variables to zero or something suitably reasonable. [/psychic debugging] | |
Re: >Any suggestion? I'd suggest that you confirm the need to do this without any kind of list. This sounds more like make-work with unreasonable restrictions than a beginner's project. Since you claim that it's a beginner's project, it's more likely that you just didn't fully understand the requirements and have … | |
Re: Read [URL="http://www.eternallyconfuzzled.com/tuts/algorithms/jsw_tut_sorting.aspx"]this article[/URL] and pick an algorithm to use. To sort strings, the easiest way is to compare with the strcmp function and swap with the strcpy function (both found in the string.h header). Note that to sort all of the strings, you'll want to keep them all in memory … | |
Re: cin.getline will give you a line from the file: [code=cplusplus] #include <iostream> int main() { char buf[1024]; if ( std::cin.getline ( buf, sizeof buf ) ) { std::cout<< buf <<'\n'; } } [/code] Ideally you would use the std::string class, but I'm not sure if you've gotten far enough in … | |
Re: >What can .net be used for? what is it good for? In my opinion .NET is best used for applications and services where the overhead of the framework is acceptable. I can't stress enough how much more pleasant GUI applications are to write in .NET than in Win32 or MFC. … | |
Re: >how do I sort both department and gender? The keys are rolled up in a single object, so all you need to do is modify your comparison for the sort. Try comparing both the department and the gender in the same if statement. | |
Re: >A field such as First Language and possibly one for additional >languages spoken might be useful for those who take issue with >people struggling to describe the problems they are having. In my experience, we're generally pretty good at determining if the communication barrier is due to legitimate language problems … | |
Re: I can't help but reply since I'm probably one of the 'Vets' the OP is talking about. ;) >why does it seem like some of the posts here are an ego-contest? I'd wager it's because programmers tend to have big egos. It's also a game, which I'll describe shortly. [QUOTE]Result … |
The End.