Forum: C++ 22 Days Ago |
| Replies: 9 Views: 208 I don't think it is doing what you think it is.
account newAccount(inType1);
newAccount.makeDeposit(ammount);
... |
Forum: C++ 22 Days Ago |
| Replies: 9 Views: 208 What it is telling you is it can't find a matching function to construct the base class 'account'.
If there is not one, change your checkingAccount constructor to call the correct account... |
Forum: C 24 Days Ago |
| Replies: 2 Views: 235 Save the result of the string compare so you wont do it twice. Then just increment a counter.
int seq_Search(char array[][MAXSIZE], int end, char *key)
{
int mid;
int first = 0;
int... |
Forum: C 25 Days Ago |
| Replies: 2 Views: 285 Insert at line 123 ...
else
{
printf("\nduplicate or unknown character\n");
}
and see what you get. |
Forum: C 25 Days Ago |
| Replies: 1 Views: 168 Just cast the return, time_t is equivalent to int for 32 bit OS.
return (int) MTIME;
To fix the printf warning include stdio.h |
Forum: C 25 Days Ago |
| Replies: 3 Views: 228 It works for both cases here.
I didn't see any glaring problems that relate to your issue.
At line 97 I think you intended something else ...
for(ctr = 0; ctr < strlen(n); ctr++)
sum +=... |
Forum: C 27 Days Ago |
| Replies: 10 Views: 769 You should be able to see how by now.
What controls space output? The variable spaceNeeded. If true it will output a space before the next character.
Now where should it be set to true?
... |
Forum: C 31 Days Ago |
| Replies: 3 Views: 258 Well it looks like that's what it's supposed to do.
It should print the hex representation of the floating point number 4.379.
But I don't see how it will compile and it will only print 3 of the... |
Forum: C 33 Days Ago |
| Replies: 10 Views: 769 This code is the same as you had. Just re-arranged a little.
I moved the sentence check first to catch the next non dot. The way it was (after the space skip) made it impossible to tell between the... |
Forum: C 33 Days Ago |
| Replies: 6 Views: 460 The first improvement I found was that you don't need to regenerate all the primes every time. Split the array into separate arrays. One global array of primes and one for factor counts.
This... |
Forum: C Oct 21st, 2009 |
| Replies: 10 Views: 769 Sorry for the double post, could not edit for some reason...
Another look, in order to catch the next non dot correctly you have to check before the skip space loop.
#define FALSE 0
#define... |
Forum: C Oct 21st, 2009 |
| Replies: 10 Views: 769 The last condition should not check for new line any more. You want to restart skipping after the last sentence now (when the count is reached as I said). In other words when you do putchar('\n');
... |
Forum: C Oct 20th, 2009 |
| Replies: 10 Views: 769 Just a few things to clear up.
1) How are existing new lines to be handled? If they should be ignored then line 35 should not output if c == EOL.
2) In the skip space loop you will skip new... |
Forum: C Oct 14th, 2009 |
| Replies: 14 Views: 476 Agreed. Saying it will crash is highly subjective.
I will try to avoid that in the future. I forget that what's 'obvious' to me is not to every one :) |
Forum: C Oct 14th, 2009 |
| Replies: 14 Views: 476 It's purely theoretical. You shouldn't have to compile it to see that it will crash.
The buffer will be filled with unknown data after the first two known values so the four bytes at BYTE *data... |
Forum: C Oct 14th, 2009 |
| Replies: 5 Views: 300 That is a typical search problem. The given solution is a 'depth first' search where you search down the chain of moves before considering other moves. Potentially more efficient is a 'breadth first'... |
Forum: C Oct 14th, 2009 |
| Replies: 14 Views: 476 Let's try it with my previous example.
struct Header {
DWORD dwMagic;
DWORD dwSize;
BYTE *data;
};
void MyFunction() |
Forum: C++ Oct 14th, 2009 |
| Replies: 5 Views: 223 I'm assuming that was a typo?
@Triztian:
Array elements follow each other contiguously in memory.
int arr[2][5] will look like this in memory
0,0 | 0,1 | 0,2 | 0,3 | 0,4 | 1,0 | 1,1 | 1,2... |
Forum: C Oct 13th, 2009 |
| Replies: 14 Views: 476 In the case of zero sized array, it was generally used as an easy way to index into a variable sized buffer ...
struct Header {
DWORD dwMagic;
DWORD dwSize;
BYTE data[];
};
... |
Forum: C Oct 13th, 2009 |
| Replies: 28 Views: 1,608 Glad it is working. One thing to check though ...
isspace(c) will be true for EOL so you will skip some line endings.
Sorry about the example not building. I've been doing c++ too long.
To... |
Forum: C Oct 12th, 2009 |
| Replies: 28 Views: 1,608 That will leave leading spaces as well.
Besides the fact it is way more complicated than needed. |
Forum: C Oct 12th, 2009 |
| Replies: 28 Views: 1,608 Make it so it's just like the first time so reset both of em ...
#define EOL '\n'
...
if(c == EOL)
{
putchar(c); |
Forum: C Oct 12th, 2009 |
| Replies: 28 Views: 1,608 Close but not quite right Aia.
This will leave a leading space and a trailing space before the line feed.
You can fix yours OSiRiSsk. Just check for the EOL and reset the flags. |
Forum: C Oct 9th, 2009 |
| Replies: 8 Views: 629 Just change your printf("%c" to printf("|%c" and printf("\n" to printf("|\n"
You should probably split the code into sections though, like: ClearArray, FillArray, and ShowArray. Then you can make... |
Forum: C Oct 9th, 2009 |
| Replies: 7 Views: 378 Also it would be a good idea to save strlen(string) and instead of doing strlen in the for loop.
int iLen = strlen(string);
for(i = 0; i < iLen; i++)
... |
Forum: C Oct 9th, 2009 |
| Replies: 28 Views: 1,608 The code as is should work right the first time. If you are reading multiple lines it will start putting leading spaces in because start is not reset for the next one. |
Forum: C Oct 9th, 2009 |
| Replies: 2 Views: 421 The stringSend member should not be part of the structure you send. It is just a 4 byte ptr that will be meaningless to the receiver.
Thus when you send it will be sizeof(struct) - sizeof(char *)... |
Forum: C Oct 9th, 2009 |
| Replies: 8 Views: 629 You can do this without the 'if' checks and with 2 nested for loops.
Break your problem up to it's smallest pieces and choose a path that solves the pieces with the least redundancy.
Smallest... |
Forum: C Oct 8th, 2009 |
| Replies: 5 Views: 300 You'll want to keep your x & y local so each move is incremented from the correct position (you'll need to pass these in as params with the starting position sent in the first call). As it is the... |
Forum: C Oct 8th, 2009 |
| Replies: 5 Views: 300 If speed is not critical use a recursive function.
GenNextMove(int depth)
{
if(depth == nMaxMove)
{
nTotalPos++;
return;
} |
Forum: C++ Sep 9th, 2008 |
| Replies: 2 Views: 778 Thank you.
It turns out (after trying the various different exception handling techniques) that the exception was being thrown from another part of the code.
The dll calls the suspect function... |
Forum: C++ Sep 9th, 2008 |
| Replies: 2 Views: 778 Im calling a function in a 3rd party dll. Somewhere down the line it hits an access violation (0xC0000005).
I wrapped the call in a try/catch but it never catches and the runtime pops up the old... |
Forum: Computer Science May 17th, 2008 |
| Replies: 0 Views: 703 Hi,
I wonder if anyone has seen a solution for a similar problem or can think of a better solution than this.
I initially tried to use Floyd-Warshall with a MAX function instead of MIN but the... |