159 Posted Topics
Re: Yes, that should be an appropriate solution. The task says that the setw argument shouldn't need to be changed manually when i grows - and your solution does just that. | |
Re: You can get all window titles by using the WinAPI function [url=http://msdn.microsoft.com/en-us/library/ms633497%28VS.85%29.aspx]EnumWindows[/url]. To get the active window, you can use GetForegroundWindow. But like all cheat protections, it can be easily bypassed. What if I just don't create a window for my cheat program and instead operate the chess program directly? … | |
Re: You need to link the C++ library statically. How to do that depends on your compiler, Google will help you there. I'm assuming VC++, since MinGW automatically links it statically. | |
Re: You're going to have to describe in detail what you're [i]really[/i] trying to do. | |
Re: You shouldn't use malloc at all. This is how you do it properly: [CODE]s_cell** cell=new s_cell*[MAP_X]; for (int x=0;x<MAP_X;x++)cell[x]=new s_cell[MAP_Y];[/CODE] Even better is the following: [CODE]vector<vector<s_cell> > cell(MAP_X,vector<s_cell>(MAP_Y));[/CODE] | |
Re: See here: [url]http://www.cplusplus.com/forum/beginner/26566/#msg141819[/url] | |
Re: When seeding a pseudo random number generator with a certain number (that's what srand does), it will always produce the same series of "random" numbers. So you should call srand just [i]once[/i] at the beginning of the program. | |
Re: First: drop Dev-C++. Not only is the IDE itself outdated, but the version of MinGW that comes with it also is. Make sure to do a clean uninstall that also gets rid of MinGW, then install Code::Blocks. As to your problem, store pointers if your objects are [i]very[/i] expensive to … | |
Re: What did you expect to happen? There [i]is[/i] no point to the right of (3|0). | |
Re: To split the string, you can use [url=http://www.boost.org/doc/libs/1_43_0/doc/html/string_algo/usage.html#id1761650]boost::split[/url] or stringstreams. For hash tables, see [url=http://www.boost.org/doc/libs/1_43_0/doc/html/unordered.html]boost::unordered_set[/url]. | |
Re: I do: [url]http://www.boost.org/doc/libs/1_43_0/[/url] boost is essentially an inofficial extension to the C++ standard library and contains many things that were not included in the standard library, but that you will need sooner or later in your programs. | |
Re: It inserts the value key at position index into the array a which currently has n used elements. The if statement checks whether the index is out of bounds and does nothing if it is and also does nothing if it isn't. | |
Re: Either move all other patients down one position or make an array of pointers to patients and allocate them dynamically. Then you can delete the patient at a certain position and mark the position as free by setting the pointer to 0. Since your array seems to play a double … | |
Re: A top-down solution, although not much different: [CODE]#include <iostream> #include <fstream> #include <vector> using namespace std; int clamp(int val,int max) { if (val<0)return 0; if (val>max)return max; return val; } int main() { ifstream file("triangle.txt"); vector<vector<int> > triangle; while (file.good()) { triangle.push_back(vector<int>(triangle.size()+1)); for (int i=0;i<triangle.back().size();i++)file >> triangle.back()[i]; } for (int … ![]() | |
Re: @tajendra Note that the coin counting must work for arbitrary coin ranges, not just the entire range. Also, you need to reduce nFalseCoinCount when appropriate. If vijayan121's solution is not fast enough (you're already compiling with -O3, right?), you can implement vector<bool>'s shifting logic yourself and then flip 32/64/128 coins … | |
Re: There is a predefined operator "ranking" which determines the order operators are evaluated in: [url]http://www.cppreference.com/wiki/operator_precedence[/url] It's basically just like in maths, e.g. products and fractions are evaluated before sums. To change that order, you can use brackets. In your above example, the brackets are superfluous. This will have the same … | |
Re: Those are references. They're basically like self-dereferencing pointers. I suggest looking them up in your C++ book. | |
Re: I'd recommend SFML if you don't need a GUI. Using SFML is child's play and they have many code examples. | |
Re: Since the code posted contains a total of ten mistakes and is also meant for a rectangle, the OP will still need to show some initiative of his own. | |
Re: [CODE]cout << "♠♣ ♥ ♦" << endl;[/CODE] does the trick. | |
Re: The block does no longer belong to the for loop, because you have a ; after the for. | |
Re: Is the declaration of ignition inside the loop? Then you shouldn't be surprised, you're recreating it and initializing it to false each time. [QUOTE]declaring ignition as true[/QUOTE] That's an assignment, not a declaration. The declaration is bool ignition; [QUOTE]Im new to the C[/QUOTE] Looks like C++ code to me. [QUOTE](ignition … | |
Re: You're pushing char pointers into the vector that become invalid when temp is changed. You need to make a vector of strings or you need allocate memory for each char array and copy the string into it. | |
Re: This would be so much easier if you just used strings, see the code example below. It would also help if you would just open your C++ book and start reading... it doesn't look like you've done that until now. This code still doesn't handle punctuation marks properly like the … | |
Re: Because you aren't calling the functions, you're just declaring them. Get rid of the int to turn them into calls. You should also look up function parameters. You should pass x, y and z as parameters to the functions instead of making them global variables. | |
Re: There are so many errors in your code that it's pointless to even start pointing them out. Why don't you just read the first few pages in your C++ book? They should tell you all you need to know to fulfill the task. | |
Re: Or [CODE] std::string reversestring(test.rbegin(),test.rend()); std::cout << reversestring;[/CODE] for that matter. | |
Re: It sounds like you might be interested in Project Euler: [url]http://projecteuler.net/[/url] It provides many problems for which you'll have to come up with different algorithms in order to solve them. | |
Re: You cannot create an OS in C and C++ alone, since it provides no way to talk with the hardware. This should get you started: [url]http://wiki.osdev.org/Main_Page[/url] | |
Re: You are supposed to turn the pseudo-code into an actual C++ program. | |
Re: [QUOTE=YoavX;1266626]it gets CPU overflowed weirdly[/QUOTE] ...what? You should really post an accurate error description in the future. As to your problem (or one of them), you're trying to free buffer even though you allocated it on the stack. So that inevitably leads to stack corruption. | |
Re: Assuming you're using Windows, you should search for "winapi recv hooking" and "winapi detours". | |
Re: You seriously need to learn how to use Google and MSDN. Here: FindFirstFile: [url]http://msdn.microsoft.com/en-us/library/aa364418%28VS.85%29.aspx[/url] FindNextFile: [url]http://msdn.microsoft.com/en-us/library/aa364428%28v=VS.85%29.aspx[/url] WIN32_FIND_DATA: [url]http://msdn.microsoft.com/en-us/library/aa365740%28v=VS.85%29.aspx[/url] More examples: [url]http://www.google.de/search?source=ig&hl=de&rlz=&=&q=findfirstfile+example&aq=0&aqi=g1&aql=&oq=findfirstfile+e&gs_rfai=[/url] | |
Re: If you store all your lines in a list, you can use a map that maps the number in front of each line to its iterator in the list. That way you can both find the line in question very quickly and any line insertions will be very cheap. | |
| |
Re: Windows also knows the concept of pipes (see CreatePipe on MSDN), although throughput is lower than on Linux. Chances are it's still fast enough for what you're trying to do, though. | |
Re: You can edit your posts, so you should do it [i]now[/i]. | |
Re: [QUOTE=;][/QUOTE] std::vector is unsuitable for this. What you are looking for is std::map. | |
Re: You should rephrase that. What do you want to do exactly? | |
Re: Depends on whether the strings in the array are null-terminated. If so, you can just construct the string using the (casted) starting address. If not, there's a constructor that takes a range. When each int element only contains a single character, you'll have to convert the desired subarray first. | |
Re: How about explaining what you're trying to do exactly? A web crawler and a program to searcb your hard disk are two different things. | |
Re: If you want to append data to the file, open it with ios::app: [code]ofstream fout("bitmaps.txt",ios::app);[/code] Can't really say anything about your code structure without having seen the code, but it's generally good to have short functions that fulfill a clearly defined task. | |
Re: The size of the allocated chunk of memory is usually stored somewhere, but that is not required and completely depends on the implementation. Imagine a specialized memory management that exclusively sets aside a few pages of memory for allocations of exactly 4 bytes. In that case the size doesn't need … | |
Re: There code itself seems okay, besides that it is poorly formatted. You need to use arrays here. If I'm guessing right, this will shrink down the code to less than 10 pages and won't give the compiler trouble anymore. | |
Re: If you need a compiler and an IDE, see here (make sure to get codeblocks-10.05mingw-setup.exe): [url]http://www.codeblocks.org/downloads/26[/url] Free online book: [url]http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html[/url] | |
Re: Check the string reference: [url]http://www.cplusplus.com/reference/string/string/substr/[/url] The second parameter is the desired [i]length[/i] of the substring, not the position of the last char. | |
Re: Make sure [i]all[/i] object files were compiled with -fPIC by doing a full rebuild of the shared library. See here as well: [url]http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=3[/url] | |
Re: [QUOTE]After entering n, the program just keeps asking for n, and does not procede. I am at a block and really not sure what is going on. I think I almost have this done![/QUOTE] I don't get... how did you run a non-compilable program? | |
Re: Better yet: [url]http://tdm-gcc.tdragon.net/download[/url] | |
Re: Are you trying to win an obfuscated code contest or something? I'm usually not a friend of unnecessary whitespace, but this is overdoing it. A readable version after sending it through a formatter: [CODE]#include <iostream> using namespace std; int main() { double** marks2d; double stud_row=4,Quiz_Col=6; double sumup=0; double* avg=new double[stud_row]; … |
The End.