6,741 Posted Topics
Re: So I tell you to go research how set_difference works and the first thing you do is post back here asking how it works with a different account? If you're that lazy, I won't bother ever helping you. | |
Re: Both are important. Duh. | |
Re: [QUOTE]Anybody know how to remove the duplicate characters in turbo c++.[/QUOTE] There are a number of ways. The brute force method is the probably simplest, where you copy each character that isn't in the other string to a result string: [code] function set_difference(str1, str2) result = "" for each c1 … | |
Re: I know how to solve your problem, but the exercise isn't about getting someone else to do your work for you, is it? Were I you, I'd start by studying up on how the predefined functions work to get a better idea of the algorithm at play. | |
Re: An error like that suggests a broken compiler installation. The way to fix it is often a re-install of the compiler. Which compiler are you using? | |
Re: [B]>predefinedClassAObject_.pointerToClassBBase = &predefinedClassBObject_;[/B] [ICODE]predefinedClassBObject[/ICODE] is destroyed when the function returns. Your pointer is dangling because it was pointing to a local object. | |
Re: KeyboardProc was used before it was declared (C++ parses from the top down). You can either add a prototype before installhook(), or move the definition of KeyboardProc to be before installhook(). As for GetKeyState, you misspelled it: [code] #include<windows.h> static HHOOK hkb=NULL; HANDLE h; BOOL __stdcall DllMain(HANDLE hModule, DWORD ul_reason_for_call, … | |
Re: Are you just removing repeated characters, or truly removing duplicates? For example, what would the output be for "aaabaaa"? If it's the former, you can use std::unique quite easily to do the job: [code] #include <algorithm> #include <iostream> #include <string> using namespace std; int main() { string s("aaaaanffddddgjkh"); s.erase(unique(s.begin(), s.end()), … | |
Re: [B]>*endPtr = make_bunny();[/B] endPtr is already a pointer to bunny, which make_bunny() returns. When you dereference endPtr, it gives you a bunny object, so you're trying to assign a pointer to a bunny object. To assign the object returned by make_bunny(), you would dereference the result of the function call: … | |
Re: [B]>#ifndef __IN_HEADERNAME >#define __IN_HEADERNAME[/B] The rules for leading underscores in names can be tricky, and it's easy to stomp all over the implementation's reserved identifiers. Unless you're intimately familiar with the rules (which you're clearly not), I'd recommend not using any leading underscores at all. | |
Re: [QUOTE]I always chringe when I see a predicate coded like this[/QUOTE] Why? Sure, you can make it more concise, but it doesn't strike me as cringe worthy. | |
Re: [QUOTE]At what point does conciseness become more important than readability[/QUOTE] I think a more interesting question is when does conciseness start to become readable? :) Code that I found obtuse ten years ago is simple now, and code that I find easy to read might baffle someone else. So where … | |
Re: The ctime library only supports a granularity down to seconds. For milliseconds you must either use a non-portable library (such as [URL="http://msdn.microsoft.com/en-us/library/ms724408"]GetTickCount()[/URL]). The Boost Date_Time library offers sub-second resolution if the underlying platform does as well (which Windows does). Standard solutions include dividing the result by CLOCKS_PER_SEC (be sure to … | |
Re: Are you using the correct format string for ParseExact()? Also note that if you just want to verify the formatting, TryParseExact() would be a better option due to returning bool instead of throwing an exception on failure: [code] CultureInfo culture = CultureInfo.InvariantCulture; DateTimeStyles style = DateTimeStyles.AssumeLocal; string time = "44:22.37"; … | |
Re: You kids learn some crazy things. In the real world, there's only one methodology: [list=1] [*]Stare at the monitor with a confused expression [*]Type feverishly [*]Stare at the monitor with a distraught expression [*]Type feverishly [*]Make an angry face [*]Pound on the keyboard [*]Repeat at #1 until you have something … | |
Re: By "doesn't seem to work" do you mean it fails to compile with an error along the lines of "'gotoxy' was not declared in this scope"? Because that's what I would expect, since gotoxy is one of those conio functions that isn't likely to be supported except on Borland compilers. … | |
![]() | Re: [QUOTE]I'd appreciate it if you didn't ask whether the attempt was successful or not.[/QUOTE] Way to answer the question without it being asked. ;) If you'd rather not have someone ask, then clearly the attempt was unsuccessful. |
Re: I think "arun" means invoke undefined behavior. Because that's what the program does. | |
Re: [B]>cout<<user;[/B] user is a pointer, you need to dereference it first: [code] cout << *user; [/code] Though bare pointers are so passé. You should prefer smart pointers unless there's good reason to do otherwise: [code] string name, pass; cout << "enter name: "; cin >> name; cout << "enter password: … | |
Re: [QUOTE]But recently I was writing a string class for myself only to learn and find out that definition of overlaoding of << can also be in the class, my question is why is this working?[/QUOTE] Magic. This definition is allowed, and has a few noticeable benefits: [list] [*]The function is … | |
Re: [QUOTE]May someone please explain to me why the rename function isn't working?[/QUOTE] rename() sets errno. Call perror() to get a more useful error message. | |
Re: [QUOTE=Ancient Dragon;1597427]many compilers do not support that construct -- the compilers will require num_grades to be a constant. g++ is one of the few compilers that recognize that construct, which is new to c++0x, which is not yet an official version of c++ standards. Use a different compiler and you … | |
Re: [QUOTE=shaikh_t;1432860]Hello Can you suggest me some topics for final year projects in Web Designing Field?[/QUOTE] You could redesign my website for free and use it as a case study for your final project. :) | |
Re: [QUOTE=WaltP;1596166]Could the reason he's [I]wasting his time[/I] is to learn to program, not outdo the compiler? There are many reasons to reprogram a built-in function -- first of which is to learn, not replace. Even in K&R they [I]wasted their time[/I] by programming built in functions -- in multiple ways.[/QUOTE] … | |
Re: [QUOTE]And why are programmers dissing it all of a sudden?[/QUOTE] I suspect a bunch of parrots just jumped on the bandwagon. Aside from the debugger interface, of which I wasn't a fan, I had no serious issues with Dev-C++ (either stable or beta). However, Dev-C++ is still a frozen project … | |
Re: That's platform specific. You need to tell your OS to run that program on boot. What OS are you using? | |
Re: The new operator throws an exception of std::bad_alloc if the allocation fails. [rhetorical question] Did you catch the exception? [/rhetorical question] | |
Re: [QUOTE]I want more indepth info/lessons about C and I don't know where to go/begin[/QUOTE] More study never hurts. Reading code and participating on active C forums (as well as having a [URL="http://www.careferencemanual.com/"]complete reference[/URL]) will go a long way over time. But the best way to improve yourself is and has … | |
Re: You still use DEVMODE. The dmPelsWidth, dmPelsHeight, and dmBitsPerPel members are what you want to update. | |
Re: sourceforge.net? freshmeat.net? Do you even know how to use google? | |
Re: [QUOTE]The ignore command will get rid of any stray characters that are in there and it won't do anything if there are no stray characters, which is what you want.[/QUOTE] That's not quite correct. The ignore function will still block for input if the stream is empty. With one edge … | |
Re: The closest so far is gcc, at least version 4.6. Visual C++ 2010 has a few features, but not the most useful ones for the everyday programmer. If you're working on Windows, I'd suggest the [URL="http://nuwen.net/mingw.html"]nuwen build[/URL] of MinGW (it offers gcc 4.6.1). The problem with nuwen is that presently … | |
Re: [QUOTE]In your callback function inside the switch statement you have char A_Function(); . What is this for?[/QUOTE] It's a declaration for A_Function(). Placing declarations at deeper than file scope is an older style, and sometimes nonsensical, but there's not really anything wrong with it. [QUOTE]it sometimes outputs values < 1 … | |
Re: [B]>#include <cassert>//what is the use of this???[/B] In that program it's not used. But <cassert> defines the assert macro, which is used for sanity checks: [code] void foo(int *p) { // Precondition: p is not a null pointer assert(p != 0); .... } [/code] Your questions boil down to "How … | |
Re: [QUOTE]i want to write a program[/QUOTE] [QUOTE]the program should be written in C i need it for "borland c"[/QUOTE] FYI, nobody here is going to write this for you. We'll help you write it yourself, but that's it. | |
Re: [QUOTE]Why ????? Because, all though the 'int' is saved in the file(in disk), a text doc wont be able to display because it only displays ascii characters.[/QUOTE] That has nothing to do with fwrite not working and everything to do with your misunderstanding of how fwrite works. fwrite directly writes … | |
![]() | Re: [QUOTE]how does it know what to get and set?[/QUOTE] Magic. The compiler basically turns it into this: [code] Blah __anonBlahBlah; Blah Blah { get { return __anonBlahBlah; } set { __anonBlahBlah = value; } } [/code] |
Re: [QUOTE]Does anyone know how to cpy from one file and redirect to another.[/QUOTE] [CODE] #include <fstream> using namespace std; int main() { ifstream in("source", ios::binary); ofstream out("destination", ios::binary); if (in) out << in.rdbuf(); } [/CODE] [QUOTE]I need the Carriage return (0D) to be present.[/QUOTE] Text mode streams will convert whatever … | |
![]() | Re: [QUOTE]Basically give the members the ability to make their own queries[/QUOTE] Or you could just, you know, remember the folks who rub you the wrong way. :icon_rolleyes: Ignoring the safety and performance concerns of supporting custom queries, consider that Daniweb's single biggest [URL="http://www.catb.org/jargon/html/P/PEBKAC.html"]PEBKAC[/URL] issue is a rampant failure to click … |
Re: [QUOTE]i want to return a string array so i can use it in my main function. how do i do this?[/QUOTE] You don't. Arrays aren't assignable, which means you'd be returning a pointer to either the array itself or a pointer to the first element. Since a local array is … | |
Re: Why do you need separate arrays? Just use the index array and a simple expression for figuring out the index. | |
Re: I have a better idea. You tell us what problem you're trying to solve, and we'll help you come up with a better algorithm. | |
Re: Would it help if the code looked like this? [code] string digits = "0123456789abcdefghijklmnopqrstuvwxyz"; int index = value % base; s = digits[index] + s; [/code] | |
Re: [QUOTE]I think this has something to do with the fact that I'm returning a const reference to an object that this function is treating as const.[/QUOTE] I think you're smoking crack if you made that connection with the given error. The problem is your syntax in calling size() and at(). … | |
Re: Not possible in the confines of standard C++. You would need either more control over the display, or more control over the input shell. What compiler and operating system are you using? | |
Re: I notice you didn't ask a question. What exactly do you want help with that doesn't correspond to "please give me the solution"? |
The End.