Search Results

Showing results 1 to 27 of 27
Search took 0.00 seconds.
Search: Posts Made By: SVR ; Forum: C and child forums
Forum: C 34 Days Ago
Replies: 2
Views: 245
Posted By SVR
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 Oct 31st, 2009
Replies: 2
Views: 306
Posted By SVR
Insert at line 123 ...


else
{
printf("\nduplicate or unknown character\n");
}


and see what you get.
Forum: C Oct 31st, 2009
Replies: 1
Views: 184
Posted By SVR
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 Oct 31st, 2009
Replies: 3
Views: 255
Posted By SVR
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 Oct 29th, 2009
Replies: 10
Views: 806
Posted By SVR
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 Oct 24th, 2009
Replies: 3
Views: 289
Posted By SVR
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 Oct 23rd, 2009
Replies: 10
Views: 806
Posted By SVR
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 Oct 23rd, 2009
Replies: 6
Views: 466
Posted By SVR
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: 806
Posted By SVR
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: 806
Posted By SVR
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: 806
Posted By SVR
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: 493
Posted By SVR
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: 493
Posted By SVR
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: 301
Posted By SVR
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: 493
Posted By SVR
Let's try it with my previous example.


struct Header {
DWORD dwMagic;
DWORD dwSize;
BYTE *data;
};

void MyFunction()
Forum: C Oct 13th, 2009
Replies: 14
Views: 493
Posted By SVR
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,628
Posted By SVR
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,628
Posted By SVR
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,628
Posted By SVR
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,628
Posted By SVR
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: 668
Posted By SVR
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: 386
Posted By SVR
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,628
Posted By SVR
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: 459
Posted By SVR
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: 668
Posted By SVR
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: 301
Posted By SVR
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: 301
Posted By SVR
If speed is not critical use a recursive function.


GenNextMove(int depth)
{
if(depth == nMaxMove)
{
nTotalPos++;
return;
}
Showing results 1 to 27 of 27

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC