# Search:

Type: Posts; User: john.c

Page 1 of 20 1

by john.c
Replies
15
Views
235

WTF?!
2. ## Thread: I want to run a counter until overflow but counting stops at 43178

by john.c
Replies
15
Views
235

### You turn on optimization with the -O flag. Try...

You turn on optimization with the -O flag. Try -O2
(That's the capital letter O.)
3. ## Thread: I want to run a counter until overflow but counting stops at 43178

by john.c
Replies
15
Views
235

### Obviously he's running into a stack limit. And...

Obviously he's running into a stack limit.
And although tail call optimization is not guaranteed by the standard, any decent compiler will do it.
But it is not done if you don't request...
4. ## Thread: I want to run a counter until overflow but counting stops at 43178

by john.c
Replies
15
Views
235

### Since it's tail recursion, as long as it's...

Since it's tail recursion, as long as it's optimized only a single stack frame would be used.
5. ## Thread: Copying prime numbers into array

by john.c
Replies
2
Views
102

### Just return the number of primes you found. ...

Just return the number of primes you found.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int checkNumber(const char *word)
6. ## Thread: Dynamic array - size calculation

by john.c
Replies
3
Views
129

### This is not correct if n is odd: 3*(n-1)*(n>>1)...

This is not correct if n is odd:
3*(n-1)*(n>>1) // or (n/2) instead of n>>1
You need to multiply n*(n-1) first to ensure that the result is even before dividing by 2.

Suppose n is 5:
(5...
7. ## Thread: Dynamic array - size calculation

by john.c
Replies
3
Views
129

### 'a' must only go up to n - 1 since 'b' must start...

'a' must only go up to n - 1 since 'b' must start at 'a + 1' but not go over 'n'. When 'a' is 1, there will be n - 1 'b's, when 'a' is n - 1 there will be 1 'b'. So the number of triples...
8. ## Thread: free(): double free detected in tcache 2 Aborted (core dumped)

by john.c
Replies
2
Views
138

### Why are you bothering to dynamically allocate...

Why are you bothering to dynamically allocate user? Just use an array.

If you want to read from a file you need to pass the FILE* pointer to readFields and use fscanf.

The "%s" format spec...
9. ## Thread: how to create and save more than 10^18 Integer Data Type?

by john.c
Replies
2
Views
163

### If you don't need more than 128 bits there are...

If you don't need more than 128 bits there are native 128-bit values available on 64-bit machines. The maximum for an unsigned 128-bit value is 340282366920938463463374607431768211455, which is about...
10. ## Thread: Maximum of the real numbers found into the input

by john.c
Replies
13
Views
342

### @christop, You're right that the word "word" is...

@christop, You're right that the word "word" is ambiguous. I just assumed it had it's "normal" meaning, but it could just mean "token" and the input could just be all numbers of the given form. I was...
11. ## Thread: Maximum of the real numbers found into the input

by john.c
Replies
13
Views
342

### @christop, I think the input is a mixture of...

@christop, I think the input is a mixture of words and numbers, e.g.:

alpha beta 3,14 gamma 145,70 delta epsilon 0012,34 zeta

There's no reason...
12. ## Thread: Maximum of the real numbers found into the input

by john.c
Replies
13
Views
342

### Two problems. It makes your program dependent on...

Two problems. It makes your program dependent on the user having that locale on their system. Also, using something like sscanf("%f",...) or strtod will allow a value without a fractional part (which...
13. ## Thread: Maximum of the real numbers found into the input

by john.c
Replies
13
Views
342

### You need to maximize the warning level of your...

You need to maximize the warning level of your compiler, pay attention to the warnings, and fix them. You have four unused variables in checkWord and you don't return anything from firstHalfNumber or...
14. ## Thread: How to code login function using UDF in C language

by john.c
Replies
10
Views
299

### Ultra-Deep Field, obviously! Speaking of which,...

Ultra-Deep Field, obviously!
Speaking of which, why is this galaxy so yellow?
15. ## Thread: Is this undefined behavior in C99?

by john.c
Replies
8
Views
206

### You have no idea what you are talking about. But...

You have no idea what you are talking about. But since you are convinced that you do, there's no point in my continuing the discussion. Good luck with that.
16. ## Thread: Is this undefined behavior in C99?

by john.c
Replies
8
Views
206

### You are misunderstanding what "undefined...

You are misunderstanding what "undefined behavior" means. It doesn't mean that it won't work or will definitely blow up in every implementation of the language. It just means that the standard itself...
17. ## Thread: Data to location

by john.c
Replies
19
Views
482

### You don't like Star Trek ?!?! 16291

You don't like Star Trek ?!?!

16291
18. ## Thread: multi-argument function pointer and enum

by john.c
Replies
16
Views
485

### 16289 Don't make me resort to the double!...

16289

Don't make me resort to the double!
(Read Salem's last post again! )
19. ## Thread: Do not understand this do..while loop

by john.c
Replies
4
Views
343

### You say "could" leave out the terminating...

You say "could" leave out the terminating semicolon, but you mean "must" leave out the terminating semicolon, or else the following will not work:

if (b)
WAIT_FOR_PERIPH(); // the...

by john.c
Replies
19
Views
482

16288

by john.c
Replies
19
Views
482

16287

by john.c
Replies
19
Views
482

16286
23. ## Thread: multi-argument function pointer and enum

by john.c
Replies
16
Views
485

Yes.

by john.c
Replies
5
Views
237

### Malcolm makes a very important point that I...

Malcolm makes a very important point that I totally forgot about.
It is "undefined behavior" to use a pointer to access memory that has been freed.
In principle, anything can happen.

by john.c
Replies
5
Views
237

### #include #include int...

#include <stdio.h>
#include <stdlib.h>

int main()
{
int *ptr; //This pointer will hold the base address of the block created
int n, i;

//// since ptr has not been initialized...
Results 1 to 25 of 500
Page 1 of 20 1