556 Posted Topics

Member Avatar for terabyte

It only appears to work, it is in fact undefined behaviour, this is exactly what it says the behaviour may be a crash or it may appear to work or anything inbetween and it may do different things every time it is run. If you put this sort of code …

Member Avatar for sepp2k
0
117
Member Avatar for nina.le.92

Line 43: you ask the user for a string but the variable str is only a single character not a string (an array of char) Your 2 arrays alpha and ALPHA seem unlikely, at this stage to be of any use. Your encrypt function just needs to read everry letter …

Member Avatar for Banfa
0
269
Member Avatar for ConfusedLearner

Your problem is in the while loop at line 9. The thing is that cin is always going to return ok (true) while it can perform the operation you have requested so the only way to break this loop is to input data that can't be converted to a number, …

Member Avatar for Banfa
0
157
Member Avatar for jingoria

Your syntax on line 7 is never going to work, it could only ever work is C was an acester of A. But you can initialise a class in its constructor from another class like this class C { public: explicit C(const A& inita) : a (inita) { } private: …

Member Avatar for Banfa
0
270
Member Avatar for CHOCHOCHO

At line 107 you are missing the const on the declaration of the inclass parameter Your declaration and definition of list_clear at lines 28 and 55 do not match

Member Avatar for Banfa
0
181
Member Avatar for wschamps42
Member Avatar for Banfa
0
155
Member Avatar for penty.kn

Also it's not really overloading, if you put both into a single program you would get an error, it has to be one or the other. True overloading, like C++ would allow both function definitions to co-exist, if this where not main. C++ also does not allow overloading of main …

Member Avatar for Nutster
0
219
Member Avatar for blackrainbowhu

You have a couple of options. 1. Read the whole line using getline into a std::string and use the various members of std::string to parse the line into the individual data members of your structure 2. Use the delimiter parameter of getline to read up to the ; delimiter in …

Member Avatar for Banfa
0
437
Member Avatar for Elixir42
Member Avatar for Sandy20

This sounds like it is a porblem caused by putting locks inside a loop without putting in anything that holds them up. The thread reading from the socket should be held up by the socket comms, that is while it is not receiving any data it should not be trying …

Member Avatar for Banfa
0
309
Member Avatar for new_developer

I feel that someone should point out that having public member variables is generally very poor practice. The coding standards at my work require all member variables to be private.

Member Avatar for Lucaci Andrew
0
5K
Member Avatar for tanmay.majumdar2

In the first program you wanted each recursion to output a result where as in the second recursion you just wanted the result of the whole recursion. You have no output (cout) calls in your recursion in either case; this does not matter for the second program as you only …

Member Avatar for Gonbe
0
396
Member Avatar for SamJo22

A simple page request from a browser looks something like GET /example.html HTTP/1.1 Host: www.example.com (actually with an extra newline at the end of it but the code parser on this site wont show it.) At line 68 - 74 of your code you make no attempt to parse this …

Member Avatar for Banfa
0
332
Member Avatar for anumash

Does database.txt use '\n' as end of line characters? Does database.txt have a '\n' on the last line in the file?

Member Avatar for deceptikon
0
408
Member Avatar for zpxix

Line 11: Undefined behaviour: you call strlen on an unititialised string, this could easily lead to memory accesses outside the boundaries of the array string. May be you meant to do this after string is requested from the user. Line 13: Format string error: %c tells scanf to get a …

Member Avatar for Banfa
0
214
Member Avatar for on93

Of course the way the function min is written it is very likely not to work, cause a segfault even because it accesses the 1000th element of an array of size 6.

Member Avatar for Banfa
-1
570
Member Avatar for alanso

You have used more loops than is necassary. The thing is once you have chosen a value of a and b you can calculate the value of c that solves the equation 2a + b - c = y. You do not need a loop that checks every value of …

Member Avatar for Banfa
0
421
Member Avatar for fyra

What you should do is 1 Not free the data at line 31, you can not know that the thread has not finished with it. Test by adding a short sleep in print_thread_id Then either 2 Use pthread_join to detect when the thread has finished running then free the memory. …

Member Avatar for Banfa
0
279
Member Avatar for falcan

This is strickingly similar to the last posts of [this thread](http://www.daniweb.com/software-development/cpp/threads/448226/assembly) yet somehow a different username. Check there for an answer.

Member Avatar for Banfa
0
52
Member Avatar for capton

Looks like A QTableWidget automatically deteles any cell widgets you set. That means that for each of the 3 cell widgets you set it will try to delete the widget individually. However you did not individually allocate those widgets, you allocated an array of widgets, that means that for 1 …

Member Avatar for capton
0
216
Member Avatar for narabo

That is because in main you pass an initial value for count to check_birthdays but you do not initialise the value you pass. This is actually undefined behaviour. A quick fix is to initialise the variable count in main (to 0) or to call check_birthdays as `check_birthdays (birthdays, people);` thereby …

Member Avatar for Banfa
0
303
Member Avatar for anumash

size_t is not terribly complicated, I think you are probably reading more into it than there is. size_t is defined in the standard as "the unsigned integer type of the result of the sizeof operator" And that is basically it, it is an unsigned integer type. It is the type …

Member Avatar for deceptikon
0
185
Member Avatar for dan.gerald

1. getMonth and getDay both need to be const methods they are called through const references in operator== 2. daysInMonth doesn't return a value for all input values 3. daysInMonth is missing a Birthday:: from its definition 4. You have some comparisons between signed and unsigned integers

Member Avatar for dan.gerald
0
507
Member Avatar for Learningvinit

I imagine this is an endian issue. When storing an integer in memory little endian processors store least significant byte first, big endian processors store most significant byte first. So the numbers are stored in memory as follows 30030 little endian machine: 4E 75 00 00 big endian machine: 00 …

Member Avatar for Learningvinit
0
600
Member Avatar for daino
Member Avatar for boris90

result2 and fileUser are both std::string, therefore the will match if the have exactly the same characters in them, same characters same order same case. If they don't match then they don't have exactly the same strings in them. This is your real question, why do result2 and fileUsernever contain …

Member Avatar for Banfa
0
193
Member Avatar for sofy

Line 24 is wrong, `x%x` is always 0 and `x%1` is also always 0 so it is the equivilent of if (0 == 0 && 0 == x) Calculating is a number is prime is not trivial (except for the first few) and I would suggest that you use a …

Member Avatar for sofy
0
363
Member Avatar for Vish0203

I believe you have misunderstood how setw works. setw sets the minimum width of the next field; if the field length is less than the set field width then the field is padded with spaces (or the given padding character) either to the left or right of the data until …

Member Avatar for Banfa
0
283
Member Avatar for Carc369

A C string is and array of char. It is zero terminated, that is the last char in the string (but not necessarily the array) is the ASCII nul or '\0' or plain 0 (different names for the same thing). All characters up to the zero terminator must be printable …

Member Avatar for Banfa
0
265
Member Avatar for phfilly

Just read it into an integer. std::string operation; int operand; cin >> operation >> operand; // verify cin is good (i.e. no input errors occured //lookup operation and call it with operand.

Member Avatar for WaltP
0
392
Member Avatar for somjit{}

To start with `scanf("%s",&sh);` is incorrect it should be `scanf("%s",sh);` because sh is an array so using it without any [] already produces a pointer to it, you don't need to de-reference it. Secondly, never, ever use `gets`, always use `fgets`, so not `gets(sh);` but `fgets(sh, sizeof sh, stdin);` it …

Member Avatar for WaltP
0
393
Member Avatar for DizaFire
Member Avatar for LastMitch

The bar only seems to be appearing when you are looking at a thread, for me it disappears when I am looking at a forum thread list which is a fairly ittitating feature in a navigation bar.

Member Avatar for LastMitch
0
243
Member Avatar for maurya10

<pedantic> Not time of day, number of seconds since the epoch passed so you get a different seed every time (as long as you don't manage to seed your PRNG twice with-in 1 second). </pedantic>

Member Avatar for Banfa
0
91
Member Avatar for Satya1994

You can't talk about 'the best' compiler, you would have to give some context, for example MSVC++ is probably the 'best' compiler if you want to create MFC programs (not that I think anyone should want to do that), on the other hand for a long time if you were …

Member Avatar for DavidB
0
294
Member Avatar for piero.costa

At line 5 you have `char* comandi[n];` but at this point n is not initialised so even if you are using C99 (as opposed to C89/C90 which doesn't allow variable length arrays) this line of code can not go well. Change the `n` for a `10` and everything works. You …

Member Avatar for Ancient Dragon
0
403
Member Avatar for saranyak

Actually while what sepp2k says is generally true for many many platforms it is not absolutely true it rather depends on the platform's hardware and how it does addressing. For example I worked with a microprocessor that used 16bit word addressing, that is each 16 bit address gave the location …

Member Avatar for sepp2k
0
105
Member Avatar for phorce

It entirely depends on the format of the file you wish to read. For example a WAV file is store as a series of samples, no special library is required to read it just read the binary data. On the other hand an mp3 file is encoded using the MPEG …

Member Avatar for Banfa
0
302
Member Avatar for baby_c

Line 14 you declare ptr as a `record *`, line 27 the function display takes as a parameter `record *[]` which is equivilent to `record **`. I am surprised that you did not get a compiler warning or error. Correct the type that the function display takes as a parameter …

Member Avatar for Banfa
0
759
Member Avatar for I_m_rude

I would say that, particularly in portable code, the C bitfield syntax is of no use. It is a syntactic sugar for accessing bits in an integer type that can easily be achieved using the bitwise operators (& | ~ << >>) the difference is that while using the bitwise …

Member Avatar for deceptikon
0
141
Member Avatar for funnyguy1

You have tried to declare all your functions inside main. You can not declare functions inside functions and while you can declare classes inside functions you probably don't want to here because then the class wont be visible to any other functions. You code layout should have this structure #include …

Member Avatar for JasonHippy
0
2K
Member Avatar for chixm8_49

> [condition] ? [statement1] : [statement2]; Strictly it is `[expression1] ? [expression2] : [expression3];` There are no such things as conditions in C only `expressions` and `statements`. `Statements` are not required to return a value but `expressions` are. `expression2` is evaluated if `expression1` evaulates to true (any non-zero number) otherwise …

Member Avatar for Banfa
0
96
Member Avatar for shanki himanshu

Correct C#Jaap, the logical and (&&) and or (||) operators use shortcut evaluation, that is if they can determin the result after evaluating the left hand expression they do not bother evaulating the right hand expression. For && this means if the left hand expression is false the right hand …

Member Avatar for Banfa
0
104
Member Avatar for shanki himanshu

strlen and sizeof should always return different values because strlen never includes the trailing '\0'. In a compleatly normal string such as `"Hello World"` with no embedded terminators `strlen` will return a value 1 less than `sizeof` returns. It they don't return different values you have a buffer overrun in …

Member Avatar for Banfa
0
549
Member Avatar for Gaiety

OK you have a mutex to protect access to you data in the threads but you do not use it when access the data in main. This is an error whenever you access the data even for read you should always lock the mutex protecting its access. It might be …

Member Avatar for Gaiety
0
215
Member Avatar for Tinnin

Which means if you added the switchs `-Wall -pedantic` to your compiler command you code would not compile (try and see) * **-Wall** - output all warnings and errors (actually not quite all a few esoteric ones still need to be explicitly enabled if you want them) * **-pedantic** - …

Member Avatar for Tinnin
0
116
Member Avatar for allomeen

>int a[10][10]; > > is same as, > >int(*a)[10]; Err, NO. The first, a is an array of 10 arrays of 10 integers. The second a is a pointer to an array of 10 integers. Assuming the first, `int a[10][10];`, then the expression `a` evaulates to a type `int(*)[10];`. Which …

Member Avatar for deceptikon
1
849
Member Avatar for I_m_rude

Yes that's pretty much it. Good practice would be to treat something that has been declared as const as const. On most of the embedded platforms I have programmed on anything declared const was put into read only memory so assignments wouldn't have worked, you can never be 100% sure …

Member Avatar for I_m_rude
0
121
Member Avatar for I_m_rude

You have multiple problems but most of them stem from lines 10 and 16. At line 16 you have detected that you have an end condition but rather than return an end condition flag you return the same value as you leaf condition at line 6. If your end condition …

Member Avatar for I_m_rude
0
92
Member Avatar for I_m_rude

You haven't got 1 quite right, arr is not "a pointer to an array of 2 elements in which each element is a pointer to a 2-D array" but rather the expression `arr` evaluates to a pointer to the first element in an array of 2 elements in which each …

Member Avatar for I_m_rude
0
263

The End.