556 Posted Topics

Member Avatar for denis_stoyanov

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 …

Member Avatar for Banfa
0
84
Member Avatar for Iam3R
Member Avatar for sunnynight

[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 …

Member Avatar for Banfa
1
6K
Member Avatar for commentator8

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 …

Member Avatar for rajuln
0
415
Member Avatar for Q8iEnG

[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. …

Member Avatar for WaltP
0
164
Member Avatar for ssDimensionss

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 …

Member Avatar for 0x69
0
6K
Member Avatar for Lukezzz

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 …

Member Avatar for Banfa
0
167
Member Avatar for jjennings11

[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 …

Member Avatar for jjennings11
0
112
Member Avatar for AltF4me

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 …

Member Avatar for AltF4me
0
120
Member Avatar for tennis

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).

Member Avatar for mrnutty
0
110
Member Avatar for Lukezzz

[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 …

Member Avatar for Lukezzz
0
149
Member Avatar for metdos

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 …

Member Avatar for metdos
0
291
Member Avatar for vathsala1

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. …

Member Avatar for jephthah
0
243
Member Avatar for b.bob

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, …

Member Avatar for Ancient Dragon
0
4K
Member Avatar for shahab.burki

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 …

Member Avatar for shahab.burki
0
205
Member Avatar for martinjcloud

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 …

Member Avatar for martinjcloud
0
139
Member Avatar for deanus

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 …

Member Avatar for deanus
0
107
Member Avatar for wittykitty

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 …

Member Avatar for wittykitty
0
117
Member Avatar for sejalpastagia

> 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 …

Member Avatar for Ancient Dragon
-1
106
Member Avatar for metdos

[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, …

Member Avatar for mattjbond
0
177
Member Avatar for sam1900

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

Member Avatar for Banfa
0
164
Member Avatar for wtvrinc

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 …

Member Avatar for Banfa
0
281
Member Avatar for MVB

[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.

Member Avatar for Salem
0
425
Member Avatar for buckkitty

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.

Member Avatar for Banfa
0
107
Member Avatar for Falmarri

[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: …

Member Avatar for webs1987
0
236
Member Avatar for tajendra

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 …

Member Avatar for Banfa
0
173
Member Avatar for Reprise

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 …

Member Avatar for Reprise
0
241
Member Avatar for prushik

@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 …

Member Avatar for Banfa
0
202
Member Avatar for merse

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.

Member Avatar for mrnutty
0
137
Member Avatar for yakovm

I think you need to be using the style WS_GROUP on line 5 in addition to what you already have.

Member Avatar for yakovm
0
253
Member Avatar for hurricane123

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.

Member Avatar for Banfa
0
90
Member Avatar for ilkeamasya
Member Avatar for Macbeth

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 …

Member Avatar for Banfa
0
231
Member Avatar for shahab.burki

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?

Member Avatar for shahab.burki
0
274
Member Avatar for MWE_QUE

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 …

Member Avatar for MWE_QUE
0
112
Member Avatar for LevyDee
Member Avatar for gaya88

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++ …

Member Avatar for thomas_naveen
0
174
Member Avatar for ilkeamasya

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 …

Member Avatar for ilkeamasya
0
91
Member Avatar for timbomo

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.

Member Avatar for mattjbond
0
414
Member Avatar for PSP1202

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 …

Member Avatar for Banfa
0
316
Member Avatar for some

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 …

Member Avatar for Banfa
0
208
Member Avatar for KBL

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.

Member Avatar for KBL
0
25K
Member Avatar for rkp728

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 …

Member Avatar for Banfa
0
359
Member Avatar for mrnobody

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.

Member Avatar for mrnobody
0
2K
Member Avatar for Unidennn

Not without using a loop or an stl algorithm. Anyway C++ has its own version of this function is() declared in <local>

Member Avatar for Unidennn
0
130
Member Avatar for guest7

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 …

Member Avatar for Banfa
0
400
Member Avatar for GooeyG

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.

Member Avatar for GooeyG
0
86
Member Avatar for dondajr

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 …

Member Avatar for dondajr
0
90
Member Avatar for ccaatty

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 …

Member Avatar for cassandy
0
105
Member Avatar for emilyhedgecock

[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 …

Member Avatar for Banfa
0
1K

The End.