556 Posted Topics
Re: Firstly your iterative version is highly in efficient. If you checked a != b between lines 10 and 11 then you could avoid all the loops and other checking when a == b. That is quite a lot of processing because you will cut out 9 * 9 * 9 … | |
Re: [code]while(fgets(line, 100, file)!=NULL) { /* keep looping until NULL pointer... */[/code] "I have detected danger Will Robinson" More specifically I have detected that line was declared [icode]char line[20];[/icode] so is a 20 byte array but you have passed a pointer to line and told fgets to copy up to 100 … | |
Re: Line 14 coupled with lines 17 and 21 result in a big error. [icode]int binary[31];[/icode] defines an array of integers with 31 entries in the array indexed as 0 - 30. Certainly not enough to hold a value for each bit in a 32 bit value. [icode]for(y = 32; y … | |
Re: [QUOTE=n.utiu;1180709] [CODE] char *myChar = const_cast <char*> strMyString.c_str (); [/CODE] [/QUOTE]In general this is a bad idea, c_str returns const because you [b]should not be changing[/b] the data pointed to by its return value. Randomly casting away the constness for no good reason is asking for trouble and undefined behaviour. … | |
Re: You have not fully taken on board the nature of floats (and doubles). it has nothing to do with the machine being 32 bits, it is the nature of how floats hold there values that they are approximations (normally good ones) that is a float is rarely 2.5 or 3.0 … | |
Re: The problem is not in how you are declaring client it is how you are doing the construction of the new object. The missing or empty parenthesis indicate that the default constructor of Sftp should be called but the compiler can not find a default cinstructor for that class. Presumably … | |
Re: [QUOTE=jjennings11;1184282]it wont compile, but shows no error messages either[/QUOTE]No either it compiles in which case it will show no errors but you may get warnings which don't stop it compiling or if fails to compile in which case you get at least 1 error. As it happens your code compiles … | |
Re: Assume a class declared like this (I have reduce it to 1 float for berevity) class MyClass { public: MyClass(float initx); setX(float newx); private: float x; } You are say since the constructor is implemented as MyClass::MyClass(float initx) { x = initx; } you could just call setX which does … | |
Re: No. If you have a derived class object DO and call DO.m then only DO.m is executed. But if you call the destructor both the derived class destructor and the base class destructor get called (in that order). | |
Re: [code]List<String^> Lines = gcnew List<String^>();[/code] Declares an object not a handle and initialises it to an empty list that you gcnew to. However since it is an object and not a handle when you try to assign to it you get an operator= unavailable error because the class List does … | |
Re: The problem is at line 12 loginRequest is created on the stack, that means that it is automatically has the lifetime of the code block it is in which is the if statement. You take pointers to it and put them on your queue but that doesn't change the fact … | |
Re: There is no standard library functions in C for serial port access because it is too platform dependent. The Win32 API does support serial ort access however mildly confusingly you have to use CreateFile to open a serial port and ReadFile and WriteFile to read and write data to it. … | |
Re: In general you can only differentiate between them by looking at the code of the function or the function documentation. However that said an argument passed by value, constant reference or constant pointer is an input argument. An argument passed by non-constant reference or non-constant pointer could be an in, … | |
Re: You might try by finding out where the segmentation fault occurs either by using a symbolic debugger or if one is unavailable the more sedge hammer method of commenting out bits of code until you find the bit that causes the crash. However I suspect that pass the buffer size … | |
Re: Sorry, what are you trying to do???? Why would you want to copy the string before allocating it? Generally the way round to do things is allocate the memory for an object and then copy the data into the object. You can not assign to the return value of strcpy … | |
Re: An agregate type is a structure or class or union that holds (possibly) an agregate of serveral members of other types. In you print function you do not have an agregate type you have a pointer to an aggreagate type. You can get the agregate type by dereferencing the pointer … | |
Re: operator+= is the in place addition operator. That is it alters the object it is called on, unlike the binary additional operator operator+ which does not alter the object it is called on at all but just returns a new result. Your impletemtation is not in place, that is it … | |
Re: > start quote: main() { int a; a=message(); } message() { printf("\n C language"); } > what is the output and what return will return to a; Since this is the C++ forum there would be no output from that since C++ does not support implicit types on functions or … | |
Re: [QUOTE=mattjbond;1181023][CODE]stable = std::auto_ptr<MyClass> ( new MyClass() );[/CODE][/QUOTE] Yes me too :-) ! I hadn't tried the compile but looking at it and assuming it would work (due to its source) I was asking myself the question, surely the auto_ptr would delete the object as soon it went out of scope, … | |
Re: When LoadLibrary fails it must be for a reason. Assuming that you have the path correct I suggest you call and print the return value from [url=http://msdn.microsoft.com/en-us/library/ms679360%28v=VS.85%29.aspx]GetLastError[/url] to get some clarificaion of what is causing the problem. You can look up the value returned from GetLastError in winerror.h | |
Re: main returns int not void (although that isn't actually causing the error it is quite a serious mistake). You define infile on both lines 47 and 68. You can only define a variable once in a single code block. You need to either re-use infile rather than redefining it or … | |
Re: [QUOTE=WaltP;1179410]Next error: look on line 21 and before for the missing ';'[/QUOTE]Or with errors of that nature (missing X before Y) look on the first line of code before the line given, 21 in this case particularly if Y is the first thing on the error line. | |
Re: resultsDaily has type double**, to use . you need the thing on the left to have a class/structure/union type. Even if you dereferenced resultsDaily a couple of time this would not be the case since its basic type is double. | |
Re: [QUOTE=Falmarri;1179607]Wrong, destructor gets called twice. Hash h; h = new Hash(string); Destructor gets called once. Hash h = new Hash(string);[/QUOTE]Neither of these are right they attempt to assign an object of type Hash* to an object of type Hash I get the following 2 errors respectively compiling this code. error: … | |
Re: Yep that would be my opinion, don't bind anything let the operating system make its own decision. A lot of relatively brilliant minds have gone into writing the algorithms that the processor uses to decide which thread/process to run on which core. Supposing you can make a better decision is … | |
Re: It sounds like your file is somehow getting truncated before you write out the data or that you are writing to a non-existing file. You need to check out both of these possibilities in full first. This [icode]outFile.write((char*)this, sizeof(A));[/icode] is a particularly poor way to write out the class data … | |
Re: @prushik You may well find it easier, initially to link through gcc (or g++) Both of these programs are really entry points onto the entire tool chain rather than actual compilers which is why you have to issue them the [icode]-c[/icode] switch to make the only compile. Similarly to can … | |
Re: In a loop like this [code]int main() { for(int ix = 0; ix<5; ix++) { MyObject obj = MyObject(ix); } } [/code]obj is constructed and destricted on every loop iteration. Put cout statements in the constructor and destructor if you wish to confirm it. | |
Re: I think you need to be using the style WS_GROUP on line 5 in addition to what you already have. | |
Re: You have not called the function myStrlen, you have output its location in memory, that is [icode]myStrlen[/icode] is not a function call it is a pointer to the function you need [icode]myStrlen("Hello World")[/icode] for a function call. | |
Re: L2 and L3 have type [icode]Row*[/icode] so [icode](L3*L3) + L2[/icode] is pointer arithmetic (except * is not valid in pointer arithmetic in that way). You want to operate on your objects not the pointers to them so a sprinkling of * is required to dereference the pointer into an object … | |
Re: EVP_EncrpytInit_ex does not exist in any files or libraries you used to try an link the program. Either you are missing a library or you have the function name wrong or the function really does not exist anywhere. I think its the second did you mean EVP_EncryptInit_ex? | |
Re: The problem is (I think) in how you define the structure [code] typedef struct { int storeNumber; char storeName[STORE_NAME_SIZE]; char phoneNumber[STORE_PHONE_SIZE]; struct STORE *link; }STORE; [/code]at line 6, you have no type struct STORE. You have a defined type STORE and an unnamed structure. if you did this [code] typedef … | |
Re: no you can't my compiler produces this error bytes.cpp:8: error: ISO C++ forbids variable-size array `a' Variable size arrays are not part of C++ (they are a part of C99) if your compiler allows that code in C++ then it is using an extension to the standard. In standard C++ … | |
Re: Your 2 variables intersection and containment are float arrays that are never initialised. You then access them by incrementing them, which in itself is undefined behaviour. Since they where not initialised they had a random initial value so the value they have after the increment is also random. Finally you … | |
Re: You do realise that in the code posted Ancient Dragon had already made that replacement? Ancient Dragon posted compilable code all you have to do is copy what (s)he did and apply it to you other function calls. | |
Re: No there is a way to get the square root of a negative number but as Ancient Dragon says the result is imaginary. The square root of -1, sqrt(-1) is assigned a special value by mathematicians, i (engineers tend to use j for the same value). You can not actually … | |
Re: You can not hardcode every string. You need a data file you can put strings into, with each string you should put data defining its fan, pan, tan, lan membership (a 1 or 0 for each one or a single field of bits defining all of them for instance. Then … | |
Re: You have a ; at the end of line 18 that should be there. However once you fix that I would expect all of these types of comparison [icode]if (pass = KazzyB)[/icode] tp cause an error, or certainly not do what you expect. | |
Re: This is C++, you should be using new not malloc. This will allow you to remove that nasty cast. Casts should be avoid if possible, basically a cast (especially a C style cast) short circuits all your compilers type checking which is bad. In you loop [icode]CSPair->[/icode] always references the … | |
Re: You probably should be overriding the [url=http://msdn.microsoft.com/en-us/library/0wwk06hc%28v=VS.71%29.aspx]OnCtrlColor[/url] handler of the parent window. Intercepting OnDraw for all your edit boxes sounds tedious. | |
Re: Not without using a loop or an stl algorithm. Anyway C++ has its own version of this function is() declared in <local> | |
Re: Is test::mypred a static member function of your class test? If not then this wont work, you can not pass a class member as a callback like that because the called code in std::partition has no object test on which to call the callback function. To access the data in … | |
Re: Sounds like you have show white space switch on in your options/preferences. If so those dots/tabs are just display artefacts Visual Studio is not saving them in the file. | |
Re: In my experience the most likely cause of that type of behaviour is another part of the program writing outside object boundaries. Or writing outside of the boundaries of the object that p2 points at The second possibility clearly can happen if there is no p2. For the first possibility … | |
Re: Its very important that the \ is the very last character on the line and is not followed by comments or any white space. If it is you will get some very unhelpful compiler errors especially if it is just a stray space some visually the code looks correct. Know … | |
Re: [code=c]void addtracks (int mp3database[]);[/code] This declares a function that takes a pointer to an int, however you want a function that takes a pointer to a musicfile. Which bit of it do you think you need to change? [code] fflush(stdin); //fflush to clear previous keyboard input[/code] Calling fflush on stdin … |
The End.