Search:

Type: Posts; User: flp1969

Page 1 of 20 1

1. Thread: Is double number even or no

by flp1969
Replies
5
Views
218

What test didn't pass? And you should ask...

What test didn't pass?

And you should ask yourself if, for example, 0.5 is even or odd.
It doesn't make any sense asking if a fraction, resulting in a non integer value, is even or odd...
...
2. Thread: Trouble with scanf

by flp1969
Replies
3
Views
157

Is this right? Maybe: int nfields =...

Is this right?

Maybe:

int nfields = sscanf(line, "%d %d %d %d", &d1, &n1, &d2, &n2);
3. Thread: delete new char[] correctly ?

by flp1969
Replies
3
Views
196

Another tip, using only ISO functions from...

Another tip, using only ISO functions from string.h:

char *foo( char *s )
{
char *p;
char tmp;
ssize_t size;

// get the size of final string.
4. Thread: How to merge two array

by flp1969
Replies
10
Views
349

I prefer to deal with pointers: #define...

I prefer to deal with pointers:

#define ARRAY_TEMS(a) (sizeof a / sizeof a[0])
int x[] = { 1, 2, 3, 4 };
int y[] = { 6, 7, 8, 9 10 };
int z[9]; // must have enough space to both x[] and y[]...
5. Thread: How to merge two array

by flp1969
Replies
10
Views
349

Well... it depends... int a[4], *p = &a[2];...

Well... it depends...

int a[4], *p = &a[2];
p[-2] = 0; // valid!. same as a[0].
6. Thread: How to set all bits in loop

by flp1969
Replies
6
Views
249

(1

(1 << 4) in binary: 0b10000

It is 00001 shifted left 4 bits.

0b10000 - 1 = 0b1111 (all 4 bits set).

Let's say you want only 1 bit set:

(1 << 1) - 1 = 0b0010 - 1 = 0b0001
7. Thread: Simple reset counter on for loop

by flp1969
Replies
3
Views
219

Please, put srand(time(NULL)) outside the loop....

Please, put srand(time(NULL)) outside the loop. Inside you risk not getting "random" values with rand(). The seed must be provided only once in your program.
8. Thread: How to set all bits in loop

by flp1969
Replies
6
Views
249

Don't need a loop: int nibbles = (1

Don't need a loop:

int nibbles = (1 << 4) - 1;
9. Thread: timeout on write() for linux pipe

by flp1969
Replies
2
Views
153

Something like this? static void...

Something like this?

static void do_nothing(int sig) {}
...
signal( SIGALRM, do_nothing );

alarm(3);
errno = 0;
write( ... );
if ( errno == EINTR ) puts( "timedout" );
10. Thread: Audio stream explanations for Windows and Linux

by flp1969
Replies
4
Views
161

You need to read the documentation, write some...

You need to read the documentation, write some code, link with the libraries and voilą!
11. Thread: Audio stream explanations for Windows and Linux

by flp1969
Replies
4
Views
161

For Linux/FreeBSD I recomend ALSA and ffmpeg (lav...

For Linux/FreeBSD I recomend ALSA and ffmpeg (lav libraries)... You can try to use SDL sound libraries as well...
12. Thread: Reverse number program

by flp1969
Replies
11
Views
314

One little thing, thou... this: #include...

One little thing, thou... this:

#include <stdio.h>

int main( void )
{
int number = -987;
int reverse = 0;

while ( number > 0 )
13. Thread: Simple way to store a 64 bit unsigned long into four unsigned short with union

by flp1969
Replies
1
Views
134

Trivial, but your code has several errors...

Trivial, but your code has several errors (exemple: shifting a signed integer left) and since this is a C language programming forum, it is completely wrong...

Here's a more direct way to convert...

by flp1969
Replies
5
Views
220

Pendulum
15. Thread: Not able to build old c Code developed in windows xp 32 bit to windows 7 64 bit

by flp1969
Replies
2
Views
155

As Salem told you, this code is an old code for...

As Salem told you, this code is an old code for MS-DOS and won't work on WINDOWS!
16. Thread: How does windows.h change the main entry function to WinMain()?

by flp1969
Replies
1
Views
137

The compiled final code isn't just YOUR code....

The compiled final code isn't just YOUR code. There is an initialization and finalization codes as well. This 'initialization' code calls main(), in console applications, but Windows calls WinMain()...
17. Thread: Set, Clear and Toggle a specific bit

by flp1969
Replies
1
Views
119

Nope: #define clear_bit( v, bit ) ( (v) &...

Nope:

#define clear_bit( v, bit ) ( (v) & ~(1U << (bit)) )
#define set_bit( v, bit ) ( (v) | (1U << (bit)) )
#define toggle_bit( v, bit ) ( (v) ^ (1U << (bit)) )
18. Thread: Odd behavor with rename() function on Raspberry Pi writting to SD Card

by flp1969
Replies
5
Views
221

rename(3) - Linux manpage...

rename(3) - Linux manpage
19. Thread: Odd behavor with rename() function on Raspberry Pi writting to SD Card

by flp1969
Replies
5
Views
221

manpages and gdb are your friends... use them...

manpages and gdb are your friends... use them...
20. Thread: scope and life time of function

by flp1969
Replies
4
Views
196

Or, declare a pointer to a function and...

Or, declare a pointer to a function and initialize this pointer to the static function:

/* module1.c */
static int f( int x ) { return x + x; } // visible to this module only;
int...
21. Thread: Having difficulty to understand pointers

by flp1969
Replies
1
Views
137

1- A pointer variable holds an address which...

1- A pointer variable holds an address which points to a single memory location. malloc() alocates (reserves) a block of memory and returns the address of the first byte;

2- Yes... The NULL...
22. Thread: Cout of unsigned char

by flp1969
Replies
15
Views
545

Nope... 'ą' is UTF+00E0 and 0xE0 is 224, not 133....

Nope... 'ą' is UTF+00E0 and 0xE0 is 224, not 133. What you are asking for is the code of 'ą' using WINDOWS-1252 (probably) codepage (or a variation of ISO-8859-1 or Latin-1).
23. Thread: Take screenshot every second with a mouse cursor

by flp1969
Replies
4
Views
139

Did you search on MSDN? Here's an example (not...

Did you search on MSDN? Here's an example (not quite what you want, but it is a start): Capturing an image
24. Thread: Am I right about dynamic memory allocation

by flp1969
Replies
2
Views
177

My view of pointers and memory: In a very...

My view of pointers and memory:

In a very simple way, when you declare a variable you are asking the compiler to reserve enough space to hold the value in the size of that type. So, "int x;", a...
25. Thread: Lotto 6/49 program

by flp1969
Replies
53
Views
1,432

for ( i = 0; i < sizeof lotto / sizeof lotto[0];...

for ( i = 0; i < sizeof lotto / sizeof lotto[0]; i++)
printf( "%d ", lotto[i] );
putchar('\n');
Results 1 to 25 of 500
Page 1 of 20 1