HANDLE hFind;
WIN32_FIND_DATA FindFileData;
if((hFind = FindFirstFile("C:/some/folder/*.txt", &FindFileData)) != INVALID_HANDLE_VALUE){
do{
printf("%s\n", FindFileData.cFileName);...
Type: Posts; User: john.c
HANDLE hFind;
WIN32_FIND_DATA FindFileData;
if((hFind = FindFirstFile("C:/some/folder/*.txt", &FindFileData)) != INVALID_HANDLE_VALUE){
do{
printf("%s\n", FindFileData.cFileName);...
WTF?!
You turn on optimization with the -O flag. Try -O2
(That's the capital letter O.)
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...
Since it's tail recursion, as long as it's optimized only a single stack frame would be used.
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)
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...
'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...
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...
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...
@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...
@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
Your variable n is unused in your code.
There's no reason...
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...
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...
Ultra-Deep Field, obviously!
Speaking of which, why is this galaxy so yellow?
https://upload.wikimedia.org/wikipedia/commons/e/e1/UDF423-SpiralGalaxy.jpg
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.
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...
You don't like Star Trek ?!?!
16291
16289
Don't make me resort to the double!
(Read Salem's last post again! )
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...
16288
16287
16286
Yes.
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.