278 Posted Topics
Re: What isn't working? What is the result, and how does it differ from what you expect? | |
Re: It makes absolutely sense that this doesn't make sense at first sight ;). [code=cpp] void Reallocate(char* Source) [/code] Here, Source is a _copy_ of char* Buffer. So modifying what Source points to will leave Buffer completely untouched. Only if you modify the thing-that-Source-points-to you will also modify the thing-that-Buffer-points-to .. … | |
Re: It could be me, but I really don't understand what you're asking - could you be more specific please? | |
Re: Did you google what the toupper function does? What parameters does it take etc. | |
Re: The board is small, so you don't need any fancy search strategy... Take this as example: [code] int row1[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 2 }; bool isInRow = false; for( int i = 0; i < 9; ++i ) if( row1[i] == NewNumber ) … | |
Re: It's impossible to say with this example. Where do you call waiting(), and where do you call getID()? How do you make sure that the clock* is valid? Maybe the Clock object that you passed by ref. to the constructor has already 'died' when you call getID(). So better show … | |
Re: ... is not an operator, are you sure he did not mean . ? Check: [url]http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B[/url] I guess the most common use of ... is in try/catch blocks: [code=cpp] try { } catch( ... ) { } [/code] This will catch all C++ exceptions | |
Re: Parameters in a function are separated by ',' not by ';' | |
Re: Why do you catch in this function, immediately after you throw? If you remove the try catch in this function, you will have to catch it at the caller's side (and this function will not return). For example: [code=cpp] try { myHeap.top() } catch( const char* e ) { cout … | |
Re: Some comments: strlen already returns the correct length, you don't need to decrease the length to account for the null-char. I don't think the revString is necessary. You can define a pointer to the start of string, and one to the end.. compare them and increase the first pointer, decrease … | |
Re: A lot is wrong... Compile with -Wall (enable all warnings) and it will tell you which functions are deprecated. As a first sweep: don't use anything from conio.h | |
Re: #1 : Your vector 'quantity' is uninitialized, which means you are trying to print garbage. #2 : Your loop is suppose to _fill_ the vector, now you are just printing it out like in #1. Also, the loop counter must be named x, not the vector itself. So if I … | |
Re: So the code you pasted works? Since card_list is in the class. + are you sure the _compiler_ is crashing? Please give us the smallest source that reproduces the problem.. including all files that we need (e.g. the card class etc.) - then we can give better suggestions. | |
Re: You can start by writing an empty main function, and other functions that the question states (ReadDials) etc. put the 8 char variables in main, and call ReadDials with those 8 variables. | |
Re: The max of rand() is system-dependent. Show us what you are doing, there may be a different reason for your program crash. | |
Re: Don't include 'as soon as possible' in your topic and post... it is rude and even made me consider not replying to you at all. You are defining the function SumN inside the body of main()... that is wrong. Each function must have its own scope. Besides that, you say: … | |
Re: Why not public (or protected, if the classes are related) getter/setter functions? If that doesn't make sense then I'm not entirely sure what your problem is, in that case... could you elaborate with an example? | |
Re: I don't really understand your question... The decision between throwing in error-cases or returning a status code is a design decision... advantage of trowing exceptions is that if you don't catch them, the program will crash, where if you just return a status code (e.g. FALSE) the caller can ignore … | |
Re: What are the types of one, two and three in this example? [code=cpp] char myString[20]; ??? one = myString; ??? two = myString[2]; ??? three = &myString[2]; [/code] strcpy takes a char* as first and second argument. | |
Re: errno_t strcpy_s( char *strDestination, size_t numberOfElements, const char *strSource ); You forgot the number of bytes you want to copy. | |
Re: How would you do this if p was a 1 dimensional array? It doesn't make sense to try and work out how 2D arrays work unless you have good knowledge of 1D arrays. So show us that you can do this with a 1D array, then I'm sure we can … | |
Re: First of all, I'd like to congratulate you on making a good post, we don't see it too often anymore around here! Firstly, I would rename 'getStudent' to 'newStudent' or something simmilar, I think it reflects the purpose more accurately. Now, newStudent is responsible for gathering all the information needed … | |
Re: You expect 9 variables, but the line only contains 8. Plus, the types that are in the file must match the types of the variables. E.g. if the line is "hello" Then: [code=cpp] int firstWord; file >> firstWork; [/code] won't work. Lastly, you should put extra braces around the file … | |
Re: You should make calcArea a pure virual funtion, by defining it as: [code=cpp] virtual void calcArea() = 0; [/code] Right now the compiler thinks that this function is unimplemented. The calcArea in the derived shapes don't necessarily need to be virual. | |
Re: Here's a beginning: [code=cpp] int main( int argc, char** argv ) { return 0; } [/code] Now, please show some effort and actually _try_ for yourself. If you then have specific questions how to do something, ask again (and SHOW us what you have done yourself). | |
Re: I'm not entirely sure if put overwrites the content at the current position (although I see no reason why it shouldn't). Can you try using f.write with a size of 1 ? | |
Re: It means that >> will return a reference to its base class, in this case istream. This allows the programmer to 'chain' >> together: cin >> iTest >> cTest >> iTest2; etc. | |
Re: Why did you put the word double there? grossPay already returns a double. So you can just remove the word double on line 10. | |
Re: How are you compiling? Do you use an IDE? It seems that Node.cpp isn't being compiled (e.g. no Node.o is created). | |
Re: 'ticket' is an integer, but you expect your user to input 'A', 'B' etc. What could go wrong? You should check if the cin >> ticket is even succeeding, before trying to use 'ticket' in the switch case. | |
![]() | Re: You want an array of size i, but i is a runtime variable. The compiler is giving you this warning because it has no idea how much space to allocate for Acts. You should look up dynamic memory allocation, or re-design your solution using STL containers. |
Re: C strings are 0 terminated, you are correctly creating the chars with size 81, and copying only 80 bytes to them, but what is the value of the last char? Exactly... it is garbage data. So, you must initialize the char array to zero, you can do this in several … | |
Re: Your cin >> in; (request the user for input) is outside the do...while loop. So you ask input once and then it's continuously 'executing' the switch case with the same 'in' value. | |
Re: [QUOTE]Lastly, the function that takes "Test" I believe takes a slightly bigger datatype than const char* try prefixing it with L--[/QUOTE] That depends if the OP is building with Unicode or multi-byte support. | |
Re: There is an installer package for boost, it's mostly .1 version behind the latest build but that should not matter. [url]http://www.boostpro.com/download/[/url] They support 2010, and allow you to install various builds (static multithreaded, dynamic multithreaded etc. etc. etc.) And you're in luck... it is for the latest version ;) | |
Re: Everything is the same except the last parameter to 'transform'. So why don't you pass this argument to 1 analysis function? [code=cpp] double analysis( const vector<Student_info>& s, type_of_last_param_to_transform t ) { ... } [/code] I've intentionally left out the type of the last parameter to transform, I assume you can … | |
Re: Exceptions do not exist in C, so including the stdlib won't do any good. I don't know the exact details, but maybe Visual C++ accepts 'catch' without any specification as to what you want to catch, and g++ doesn't. In any case, I suggest you specify what exceptions you want … | |
Re: Your use of brackets indicates that you don't fully understand the do...while. You're writing your code like: [code=cpp] do { ...something } while( light == false ); { ...do something else } [/code] There are no statements in the do...while that will ever change the light boolean, and the part … | |
Re: Never flush the input stream with fflush [code=cpp] fflush( stdin); // wrong! [/code] There is a sticky on this forum that nicely explains how to deal with this problem. | |
Re: Think about what you're doing. You know that if you want a max random value of 20, you do: rand()%20; So this will generate something between 0 and 20. Now the problem starts when you try to deal with the min value, you simply add min(10) to the randomly generated … | |
Re: The 'math' in your if statements is very sloppy, it's hardly readable what's going on. First off, why are you doing stuff like [code=cpp] if( (g.y/3)*3 == something ) [/code] g.y/3 * 3 is the same as g.y So the two if reads: [code=cpp] if( g.y+k == g.y && g.x+l … | |
Re: You are including gradebook.h from two files, so the compiler will parse it twice. By doing so it will throw errors because of something like 'XXX already defined in blabla.o'. To prevent this, you should always 'guard' your header files. So GradeBook.h should be: [code=cpp] #ifndef GRADEBOOK_H_INCLUDED #define GRADEBOOK_H_INCLUDED // … | |
Re: I find a lot of things important, here is a summary: [code=cpp] int myFunction( int arg1, int arg2 ) { if( 2 == arg1 ) // would throw error if I'd write 2 = argc1 by mistake return; // And I generally thing it makes sense to write the constant … | |
Re: I just write: [code=cpp] if( 2 == a ) return true; return false; [/code] | |
Re: Be more precise in your question.. else you are unlikely to get homework help. This encrypt function you pasted(next time use code tags please), is it exactly like in your code? If so... the compiller errors should be obvious enough... So, tell us what errors you are getting, why do … | |
Re: You can't read the letter a from a file, and then assign a variable with the name a really dynamically. I guess if the variable names that you read from the file are only a,b,c etc. you could put them in an array, using the integral value of 'a' as … | |
Re: CreateThread doesn't take a pointer to a class's method, let's read the error message together: Your argument type: 'DWORD (PMessenger:: )(void*)' Expected arg type: 'DWORD (*)(void*)' So CreateThread is expecting a pointer to a function that returns a DWORD and takes void* as argument. There are several ways to 'beat' … | |
Re: Why do you want to convert the numbers to string first, and then back to integer? I guess you want to do this so that from "93" you can get the 9 and 3 seperately and do the calculations... but that would actually prove that you haven't even read the … |
The End.