6,741 Posted Topics
Re: To be honest, the code is very poorly written. There's no discernible structure, almost to the point of calling it spaghetti code, and you go about things in a highly manual way. I won't go into specific coding advice because I'm totally disinclined to read through over 2000 lines of … | |
Re: [QUOTE=death_oclock;1445346]Try using [ICODE]printf("Greetings, human!");[/ICODE] (just a guess, honestly)[/QUOTE] That's subtly different because you didn't include a newline at the end. While printf is the function you'll see most in hello world programs, puts works just fine. | |
Re: I'd take physics, but you're not me. Just pick the one you're most interested in. | |
It's not uncommon to have a mental image of people online that is a complete mismatch with their real world appearance. I thought it would be interesting to see how different members of Daniweb are perceived by their peers. Pick any members you find interesting and describe how you imagine … | |
Re: If this is a serious project (as opposed to something for learning Unicode), I'd suggest [URL="http://site.icu-project.org/"]ICU[/URL]. Managing Unicode is a bitch without a good library. | |
Re: The following is a common error: [code] #include <algorithm> #include <iostream> #include <string> #include <cctype> int main() { std::string line; std::cout<<"Enter a line: "; if (getline(std::cin, line)) { std::cout<<"Before: "<< line <<'\n'; // This is wrong! std::transform(line.begin(), line.end(), line.begin(), std::toupper); std::cout<<"After: "<< line <<'\n'; } } [/code] What's the problem? … | |
Re: You need braces around the outer loop in main: [code] for(i=0;i<2;i++) { printf("\n"); for(j=0;j<2;j++) printf("%d \t",result[i][j]); } [/code] Braces may only be omitted if the loop body consists of a single statement. | |
Re: [LIST] [*]You need to include <string> to use the std::string class. [*]Your while loop in error_check is missing a closing brace. [*][ICODE]if(test_command == true)[/ICODE] should be [ICODE]if(test_command() == true)[/ICODE]. Otherwise you're comparing a pointer to a function against true. You can also remove the [ICODE]== true[/ICODE] part because it's implicit: … | |
Re: Throw the object and catch by reference or const reference. There's no need for dynamic allocation. Your second example is conventional. | |
Re: [QUOTE]it technically still stays in memory until you overwrite the previous value correct?[/QUOTE] That's one valid result, yes. [QUOTE]is the memory freed back to the O/S and the value still remain in that memory block that was used?[/QUOTE] That's also a valid result, conceptually. The problem with these questions is … | |
Re: [QUOTE]I know the obvious 4 things[/QUOTE] All four of which are not strictly correct. I suspect your teacher is oversimplifying to the point of being wrong, in which case your best bet is to ask him what the six things are and why. I could speculate about the other two … | |
Re: What are you not sure about? And please don't say "I don't know how to start", because that's a sad excuse I see far too often. | |
Re: This is more of a job for something like strrchr. Assuming you have the line in memory already: [code] #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { const char *line = "This$is$my$Input$203"; const char *start = strrchr(line, '$'); if (start != NULL) { /* Error checking omitted for brevity … | |
Re: [B]>while(!text.eof())[/B] This is an off-by-one error because eof only returns true [i]after[/i] you've attempted to read beyond end-of-file. So you'll have one final iteration of the loop where get fails, but you still process b (from the previous iteration). You can use the result of get as a condition, which … | |
Re: You need to make three changes for the code to work as intended: [list=1] [*]Add [ICODE]#include <string>[/ICODE] to your headers [*]Change [ICODE]char Name;[/ICODE] to [ICODE]string Name;[/ICODE] [*]Change [ICODE]cin >> Name[/ICODE]; to [ICODE]getline(cin, Name);[/ICODE] [/list] There are two problems: first, char is only a single character type, not a string type. … | |
Re: First write your C++ code with C linkage and a compatible interface: [code] #include <iostream> extern "C" void helloWorld() { std::cout<<"hello world\n"; } [/code] Compile that into an object file. Now switch over to C: [code] #include <stdio.h> extern void helloWorld(void); int main(void) { helloWorld(); return 0; } [/code] Compile … | |
Re: Are you sending both a key down and key up event? [code] keybd_event(VK_RETURN, 0x9c, 0, 0); keybd_event(VK_RETURN, 0x9c, KEYEVENTF_KEYUP, 0); [/code] Return and Enter are the same key, by the way, just with varying names printed on the keyboard. | |
Re: If these are threads within the same process as opposed to threads in different processes, you can use a thread-safe data structure to share these signals. In my opinion that's easier than implementing an inter-process communication mechanism just for threads. | |
Re: Can you compile? Does it fail with a runtime error? Does it run successfully but with unexpected behavior? Throw us a bone here. Just posting code and asking "what's wrong?" is a fantastic way to get ignored. | |
Re: A segmentation fault in this case probably means you accessed one of the arrays out of bounds. Start up a debugger and keep a watch on your indices. | |
Re: You have one loop counting up. Add another one that counts down (the reverse of your counting up loop) before printing the newline. | |
Re: [QUOTE]I can't help but think data binding seems unnecessarily complicated...[/QUOTE] Implement equivalent behavior manually a few times and you'll begin to see how data binding makes life simpler. Of course, there's quite a learning curve in my experience, because binding can create frustratingly difficult to fix bugs. But once you … | |
Re: [QUOTE]up up[/QUOTE] Bummer. I was going to help you until I saw this bump. How arrogant and presumptuous. Bye bye. | |
Re: [QUOTE]what is the (char **) before the &str1 and &str2?[/QUOTE] It's an unnecessary type cast. You're forcing &str1 and &str2 into the type between parens (a type that they already have). | |
Re: The member function you're trying to use is called is_open, not open. | |
Re: You probably want to compare i against 12 rather than floorNum: [code] #include <iostream> int main() { for (int i = 0; i < 20; i++) { if (i == 12) continue; std::cout<< i <<'\n'; } } [/code] | |
Re: Pointers to member functions and pointers to void are not compatible types. Figure out another solution that doesn't require this conversion. | |
Re: What's endl supposed to do when applied to cin? | |
Re: I'm not sure why you thought you could fail to close a string with a double quote, then start a new string and the compiler would somehow know to concatenate them. As long as there's nothing but whitespace between two string literals you can get that effect, but the strings … | |
Re: [QUOTE]sizeof(pste_msg) is giving 64[/QUOTE] Yes, because that's the size of the array. You're making a distinction between the memory capacity and the functional size. The capacity is how many items could possibly be stored in the array, while the functional size is how full the array is in terms of … | |
Re: [QUOTE]Sorry I didn't understood your reply.[/QUOTE] I didn't get the connection either. In your case you need to build the value byte by byte, which initially suggests bitwise operations, but there's a BitConverter class that will do what you want (unless you want something strange): [code] using System; namespace Project1 … | |
Re: Provided the table has a primary key, you can easily generate the SQL to update with a SqlCommandBuilder and actually do the updates with a SqlDataAdapter: [code] using (var cmd = new SqlCommand(selectQuery, connection)) { using (var da = new SqlDataAdapter(cmd)) { using (var cb = new SqlCommandBuilder(da)) da.Update(table); } … | |
Re: [QUOTE]can u tell me the functions which is to be used.[/QUOTE] It's not that easy. There aren't any standard functions for processing image formats. You need to use a third party library or manually process the [URL="http://www.wotsit.org/list.asp?search=jpg&button=GO!"]file format[/URL]. | |
Re: [QUOTE]is this statement correct?[/QUOTE] Nope, but there are caveats. You can't directly access C++-specific features without wrapping them in a C-compatible interface. This is done with the extern "C" construct to force C linkage and disable name mangling: [code] extern "C" void c_send_key(const char *key) { // ... } [/code] … | |
Re: Existential question: If room 5 doesn't exist, are the lights on? ;) | |
Re: [QUOTE]I can't find any mention of what happens to that object after the exception is finished[/QUOTE] Finished by being caught and handled, or finished by being unhandled? In the former case, the destructor is properly called and the object ends after the final exception handler completes. In the latter case, … | |
Re: It takes a little thought in designing your base class for polymorphism. Without any clue as to the data you're working with, I'd start with something like this: [code] class base { public: virtual data_type value() const = 0; int compare(const base& lhs, const base& rhs) { if (lhs.value() == … | |
Re: Did you hit your head and get amnesia or something? I answered all parts of this exact question in the only other thread you've posted on Daniweb. | |
Re: [QUOTE]I want to encrypt and decrypt a password using c#.net.[/QUOTE] Don't encrypt your passwords. You should use a method that isn't reversible, which is why cryptographically secure one-way hashing is a common practice. Add a salt to the password (so identical passwords don't produce the same hash), then hash the … | |
Re: Your solution is fine, though if you fine yourself naming variables 1, 2, 3, etc., you really want an array instead: [code] #include <iostream> using namespace std; int main() { int iCouner, iNum[5], iRev = 0; int iWhole = 12321; for (iCouner = 10000; iCouner >= 1; iCouner /= 10) … | |
Re: [B]>DNA Mate = *(testDNA.CrossoverMutate(testDNA2));[/B] The copy constructor will be called here to initialize Mate with the dereferenced pointer. If you don't want that happening, make Mate a pointer as well: [code] DNA *Mate = testDNA.CrossoverMutate(testDNA2); [/code] | |
Re: [QUOTE]The void* data = tail->data; isn't working.[/QUOTE] What do you mean by "isn't working"? The code you posted clearly isn't your actual code, so I can't say for sure what the problem is. | |
Re: Why in the world do you need to create a TSR? Those are about twenty years obsolete, and pretty much only usable on a true DOS system. | |
Re: Unless you need something special, it would be easier to convert the bits to a string and do string searches. Then the problem is trivial. | |
Re: Wow, that behavior reeks of malware. | |
Re: [QUOTE]if so then why is the return type named int instead of char?[/QUOTE] For the same reason the parameter type is int instead of char, and why getchar returns int: to support EOF. If EOF were representable by char, how would you know the difference between EOF and a legitimate … | |
Re: count is reinitialized to 0 with every iteration of the loop, so any changes you make to it will be lost on the next iteration. | |
Re: Try to open it for reading. If it opens, it exists. | |
Re: [QUOTE]ref class does not have a user-defined copy constructor[/QUOTE] I bet you're using stack semantics with a copy constructor expecting managed references: [code] using namespace System; ref class example { public: example() { Console::WriteLine("Default constructor"); } example(const example^ ref) { Console::WriteLine("Reference copy contructor"); } }; int main(array<String ^> ^args) { … |
The End.