556 Posted Topics

Member Avatar for adhirgukt

Fantastic post Schol-R-LEA except that sockets are one of the few things you don't get through Windows.h you have to explicitly include WinSock2.h :p Also with some rather inverted logic because Windows.h is soooo big it can slow down compilation times so there are several symbols you can #define so …

Member Avatar for Banfa
0
254
Member Avatar for Nikolas9896

Works fine for me using mingw 4.5.2 which is a c99 compiler. The only thing I would say is that the third line of `StrCpy` int size_destination = StrLen( destination ); // !!!! Every time zero is dangerous because you have no guarantee at all that the destination pointer currently …

Member Avatar for Banfa
0
211
Member Avatar for A_3

You will be very stuck if you can only use standard libraries because communication with a COM port is not part of the standard library and you normally have to use some 3rd party platform library. When sending AT commands you need to be very careful with you line endings …

Member Avatar for A_3
0
209
Member Avatar for DS9596

> Char "is a simbol" found in ASCII code. Not really, ASCII is a way of encoding alaphbetic (and other) symbols as a number and defines numbers in the range 0 - 255. And a `char` is an integer data type. > All characters can be converted into numbers in …

Member Avatar for Ancient Dragon
0
428
Member Avatar for ubhart

Understanding the problem is very import to this kind of problem because while you may have to brute force the final solution understanding the problem can help you reduce the complexity making that brute force attack easier. For example in the problem of placing 8 chess queens on a chess …

Member Avatar for ubhart
0
396
Member Avatar for neha_8

At lines 21 and 35 you have used this construct `(*a)++` where `a` is a `char*`. Think about what this does ... Because of the \* in `(*a)++` you do not increament the pointer `a` but rather what it points to, a char. You almost certain meant to increment the …

Member Avatar for neha_8
0
194
Member Avatar for ceelos1974

Remeber a file is just a stream (or an array if you like) of characters. There are no lines that is just how some programs present the data to you, the use a special character or character combination (newline '\n' or carridge return '\r' or a combination of the 2) …

Member Avatar for Ancient Dragon
0
146
Member Avatar for ravi_14

When you type in that letter at line 9 cin enters an error state because it can not complete the requested operation, input a number. Additionally the letter you typed is left in the input buffer. This means that at line 25 cin is still in an error state because …

Member Avatar for Banfa
0
207
Member Avatar for ravi_14

What was i initialised to before the loop started? This should work i=a.begin(); while(i!=a.end()) { cout<<*i; i++; }

Member Avatar for Banfa
0
208
Member Avatar for newbiewwcode
Member Avatar for Ancient Dragon
0
365
Member Avatar for Elixir42

It is hard to tell without seeing the definitions of g_spEngineLog and BOOSTSP although I am guessing from the name that it is a smart pointer defined by the Boost library. Assuming that g_spEngineLog is also a BOOSTSP and that BOOSTSP has the normal operation for a smart pointer (i.e. …

Member Avatar for Banfa
0
285
Member Avatar for johnas.delacruz

A 64bit integer is the largest native type currently in C++. However you are not the first person to have this problem and the way round it is to use a big integer classes. Classes of this nature can normally hold any number of digits which they do by using …

Member Avatar for David W
0
471
Member Avatar for rabadiyaronak

This is because floating point types (float, double, long double) only hold an approximation to the value you think they hold because of the way the value is encoded into the available memory (normally 4 or 8 bytes). e.g. You assigned 22.7 to d but actually it holds that as …

Member Avatar for jwenting
0
298
Member Avatar for glao

In `int **d=&a[0];` d has type `int**` and a has type `int*`. The question is if a has type `int*` what is the type of the expression `&a[0]`? This isn't to hard to determine because using the array index operator gets rid of a level of indirection so if a …

Member Avatar for Banfa
0
211
Member Avatar for Sreya_1

Personally I would recomend the [Comb Sort](en.wikipedia.org/wiki/Comb_sort) algorithm rather than bubble sort which tends to be more efficient in the average case than Bubble sort but isn't that much more complex. I have used it on a microprocessor (PIC) implementation with limited flash and ram (the list being sorted took …

Member Avatar for Banfa
0
146
Member Avatar for janith.amarawickrama

Instead of `collection[2].GetId()` use `collection.at(2).GetId()` the difference between these 2 calls is that calling `at` throws an exception if the index is out of range where using `[]` just does something undefined. Assuming the index is in range then it is not a problem with the containers but what they …

Member Avatar for Banfa
0
514
Member Avatar for neyoibarra

Line 41 - 43 you output to the closed file `newemployee` instead of `dir`

Member Avatar for Ancient Dragon
0
105
Member Avatar for evaldaskowka

I think you have a problem at lines 2 and 3 // for(a;a<sum;a++) { if(zaide[a] > 0) { The initial expression at line 2 `a` looks wrong, did you mean `a=0`? Otherwise a is just forever getting bigger and you have not shown where you initialise a. Then at 3 …

Member Avatar for evaldaskowka
0
414
Member Avatar for glao

Yes, which every thing you are going to make major has to be the outside loop, the equation doesn't need changing. Think about how a 3 by 2 matrix is layed out in memory if O is the offset to the first cell the each cell has the memory location …

Member Avatar for David W
0
439
Member Avatar for ajit.nayak

This code appears to lack design additionally it appears to have C++ elements but you have posted it into the C forum. If I was going to pick on 1 thing then I do not think the variable button_counter is doing you any favours. Counting the button presses is not …

Member Avatar for Banfa
0
162
Member Avatar for ReaseySo
Member Avatar for jnawrocki
0
472
Member Avatar for ashishkadam0220

The question does not seem to preclude the use of a human processor so how about #include <string> #include <iostream> int main() { std::string text; std::string reversed; std::cout << "Please enter the string to reverse: " << std::flush; std::getline(std::cin, text); std::cout << std::endl; std::cout << "Please enter the reverse of …

Member Avatar for Ancient Dragon
0
311
Member Avatar for Suzie999

If you want to run a command in a command prompt you need to use the /c or /k switches before the command line, i.e. `"C:\Windows\System32\cmd.exe /c ping google.co.uk"` Try cmd /? at a command prompt

Member Avatar for Suzie999
0
324
Member Avatar for awais ch

You take it in as a string and then parse it into its constituent parts and interpret it. std::string expression std::getline(cin, expression); // Parse string here

Member Avatar for Banfa
0
51
Member Avatar for glao

Well you code compiles and links for me with exactly the commands you have given with the sole addition of #includes of cstdio and cstdlib to the top of your source files. Also note that the array subscription operator has a higher preceedence than pointer indirection \* so `*A[j+i*N]` is …

Member Avatar for glao
0
239
Member Avatar for Damian_2

The actual code causing the problem is in line 84 - 90 of your code. Note that the solutions suggested so far would fix this because they would force you to fix this code. In these lines you get the students scores and store then in the vector of the …

Member Avatar for rubberman
0
436
Member Avatar for Banfa

So was I the only person for who DaniWeb was offline between 10am - 12noon UTC? Or have I missed a downtime notice somewhere?

Member Avatar for Dani
0
108
Member Avatar for narvey ann

It should be noted that for finding primes between in the range 1 - 100 any of the sieves are overkill of a high order. > since 1 is prime Actually most university level matamaticians no longer think of 1 as prime, it is just a (very) special case. As …

Member Avatar for rubberman
-1
238
Member Avatar for Rahul47

There are a couple of negative implications. Firstly if you compile and run a program on 1 machine that writes a structure directly to a file in binary form using something like fwrite and reads it using fread and then you try and compile and run the same programme on …

Member Avatar for ddanbe
0
214
Member Avatar for Rahul47

The `(char *)` is the cast command it tells the compiler what cawst you wish to make, in this case float\* to char\*. Note that casts of this type are not necessarily safe although I have seen such casts reasonbly often. The at line 7 you tell printf you are …

Member Avatar for ddanbe
0
168
Member Avatar for chubbyy.putto

You have 2 problems and 1 unecessary variable. The unecessary variable is being because the one place you use it, line 30, you could simply use index+1. U think this is better because it ties everything together through the single variable and properly maintains the relationship that element n in …

Member Avatar for Banfa
0
198
Member Avatar for momal

Personally I would ignore "(a Big-Oh answer will do)" and give an exact answer. You have the formula for fine after n days fine = 2^(2^(n-1)) The second question is how many days will it take to for the fine to reach D (i.e. when fine = D) all you …

Member Avatar for momal
0
2K
Member Avatar for Rahul47

An arry variable does not "point" at anything, it is an array with assigned memory and the properties of an array. On of the properties of an array is that when its symbol is used without an index it decays to a pointer to the first item in the array. …

Member Avatar for Banfa
0
205
Member Avatar for V3N0M

Think about what you are doing, inputing a 1 x 5 array of strings. The first question is is that what you really meant because an array index with a size of 1 is quite odd and rarely used? For example this `char i2DArray[1][5];` and this `char i2DArray[5];` allocate exactly …

Member Avatar for V3N0M
0
150
Member Avatar for CoolAtt

Does it work? It prints "Inside A!!!" but does it print a number on the next line? If not then your program silently crashed. It can get into A::func and print the first line (which is what my windows implementation does before reporting a crash at the next line) because …

Member Avatar for CoolAtt
0
320
Member Avatar for folabidowu

Normally it's liters/100 kilometers but ignoring that detail. If you have C in miles/gallon then you need to do 3 convertions miles -> kilometers = times by 1.609 gallon -> liters = times by 3.785 (but note that gallons in underneath the line distance/volume -> volume/distance = 1/x so C …

Member Avatar for Banfa
0
791
Member Avatar for COKEDUDE

Line 1: strings is not an array of strings it is an array of pointer to char which means... Line 7: All the entries in strings are pointed to the same buffer, nam Also k @ lines 7/8 and i @ line 10 are not mentioned anywhere else so we …

Member Avatar for Rolf_2
0
273
Member Avatar for Seba Sama

When using rundll32. Read the description of this function, if you pass extra parameters on the command line of rundll32 then it passes a pointer to the parameters to the function it is calling. That means a function called with parameters through rundll32 must take a `const char *` as …

Member Avatar for Seba Sama
0
198
Member Avatar for Geowil

This pNResults.push_back(planetName()); for (i2 = 0; i2 <= cols; i2++) { switch(i2) { case 1: pNResults.at(i).pName = string((char*)sqlite3_column_text(statement,i2)); break; default: break; } } can be written more efficiently as planetName planet; if (cols >= 1) { planet.pName = (char*)sqlite3_column_text(statement,1); } pNResults.push_back(planet); it seems to me that the most likely problem …

Member Avatar for Geowil
0
1K
Member Avatar for cherrymae.calma

You aren't going to use ifstream or ofstream without including the relevant header. That is what the header is for, to allow you to use the class/declarations.

Member Avatar for deceptikon
0
112
Member Avatar for yann.bohbot.9

You can do the whole thing as a recursive function without a while loop. The sudo code would look something like PrintBinary(Number) { IF Number is 0 Return // End Case Get Least Significant Bit Number = Number With Least Significant Bit Removed PrintBinary(Number) Print Least Significant Bit } Because …

Member Avatar for Banfa
0
147
Member Avatar for kiya ko

Start with the values 0 and 1 each value in the series is made up by adding the previous 2 values so 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3 2 + 3 = 5 3 + 5 = 8 5 + 8 …

Member Avatar for Banfa
0
198
Member Avatar for triumphost

You have this wrong arr[k + width * (j + depth * i)] = l++; //works just fine. perfect. Compare with your 2D example, in that it is the outer loop variable that is missing from the calculation but that is not the case here. It works only because you …

Member Avatar for Banfa
0
996
Member Avatar for yann.bohbot.9

You shouldn't need 2 nested loops, I single for loop should be enough for this. If you are testing just the last input value then you shouldn't need 3 variables, 2 should be enough. Is this allowable? enter a number: 5 enter a number other than 5: 6 enter a …

Member Avatar for Banfa
0
185
Member Avatar for duskoKoscica

The way you have written Functions.h is more than something I don't like. The moment you start creating projects with more than 1 cpp file this approach will cause you errors because you will have multiple definitions of all the functions you have put into your header. Headers should only …

Member Avatar for duskoKoscica
0
364
Member Avatar for Sasquadge

The problem is your representation of the data (which of course then effects all your code). You have represented the data in the way you think about it as a human not in a way that makes it convienient to process has a computer. BTW at least at line 26 …

Member Avatar for Banfa
0
619
Member Avatar for nitish.mohiputlall

It should be noted that b should also be a floating point number, or alternatively it should be balance in pennies not dollars (or what ever currency you're using). Also repeatedly doing b = b\*(1.0F+(r/1200.0F)); is going to give you compond interest. For example if your starting balance is $1000 …

Member Avatar for Banfa
0
183
Member Avatar for COKEDUDE

You appear to be processing a file that contains a list of 1 line records. In you case the records are simple "<name> <number>" however I would always approch this by reading the entire record before processing it while(Read Line From File = Success) { Process Line } You could …

Member Avatar for COKEDUDE
0
309
Member Avatar for jursnamo
Member Avatar for Banfa
0
158
Member Avatar for mrnutty

[QUOTE=Ancient Dragon;1770624]Really?? How do you get ardav out of mississippi?[/QUOTE] uuencode64 ? Mine is an acronym for: BenAtNoFixedAbode Which I use in a number of email addresses; this was chosen when I went on holiday to Vietnam in 1999. I wanted an web email address to keep in touch with …

Member Avatar for Reverend Jim
0
687

The End.