dont the pthread_cond_broadcasts accumulate so if I call pthread_cond_broadcast a 100 times and then finally a

just use sprintf(3)

if you don`t understand… THIS IS SHOUTING!!!!!!!!!!!!!!! this is highlightening the word PROGRAMME
sphex:
it must be passed as argv[1]

byebye

you do not listen.

how do you use pthread_cond_wait() and pthread_cond_broadcast(), so that you only send a pthread_cond_broadcast() when you know there are threads blocking on pthread_cond_wait()?

why do you care?

hi. is there a way to stop gcc from including all symbol names in the executable? i tried -s and strip

what's wrong with strip?

perhaps -exported_symbols_list

it strips the debug info, but the global symbols are still in the exe

then you're using it wrong

don't the pthread_cond_broadcast()s accumulate, so if I call pthread_cond_broadcast() a 100 times, and then finally a thread calls pthread_cond_wait() it will immediately return due to the previous broadcast calls?

no.

thread1: pthread_mutex_lock(foo); somevar=1; pthread_cond_wait(foo,bar); thread2: pthread_mutex_lock(foo); if(somevar) pthread_cond_broadcast(bar); pthread_mutex_unlock(foo);

still symbol names.. (i am using mingw)

wulf is unfortunately a very silly person

I tried that, but I get deadlocks

you've missed the point of condition variables
they're not counting semaphores.

what do you believe might be wrong this time? ;-)

you've completely missed the point of what a condition variable is for.
a condition variable is something that you can sleep on so that when something interesting happens you can be woken up.

wahts the normal way to c omment out multiple lines in an ide ?

broadcasting to a condition variable just tells all current sleepers 'wake up, and see if something interesting happened'

/* … */

no accumulation, no counting, etc.

no i mean using the ide

so you appear to be trying to solve a non-problem

depends on your ide

c-a-f94

whats the most widely used ?

vim?

vs

I think I may have miss-read the pthread_cond_wait man page…….. I'm going to take a long walk off a short cliff….

not only that, but spurious wakes are allowed.

what do you mean?

I'm always willing to learn..

"pthreads primer" is available on the net

you can wake them up randomly

on some swedish university

it won't affect the semantics of a correctly written program

i don't know how legal it is, but google search gives you the PDF as 1st hit
unless they've removed it

my threaded programs usually work and I use similar code like the above

so what?

so, you call me silly and tell me I've got ne clue of anything

"work" or "appear to work" ?

work.

it's a big difference with threaded programs.
why are you so sure?

what does that gibberish have to do with nobody's misunderstanding of condition variables?

tests didn't fail (which doesn't say anything), and I kind of proved that it always works

so … what did that code have to do with nobody's problem?

with his real problem, probably nothing

absolutely nothing - so why give it as advice?

because he asked for this (:

hello

no, he didn't.

char input[9999*(2+sizeof(char*))],*index_=input,*bfptr=index_+9999,
**stack=(char**)(input+2*9999); — is there any reason this last statement would not be portable?

the dictionary definition should work. a condition variable implies a predicate, the predicate indicates if work should take place rather than the mere return from the pthread_cond_wait call.

casting a char * to a char ** is not portable
likewise, what is stack?

in a perverse way :P
oh misread
I'm just trying to reinterpret the memory

I think I know what you mean, thanks

that's not portable.

char is not guarenteed to be at least 1 byte?

hi, if i create a thread with pthread_create(), shouldn't the programm go ahead in the main routine, not waiting for the thread to finish?

actually I should have put sizeof(char**)

what does that have to do with char **?

but eh

perhaps.

What makes you think it doesn't?

i didn't even join the thread with pthread_join( )

my idea is reinterpret the memory; I've said I want the size of the input to be 9999* (2+sizeof(char**)) [at least, that was what I meant ^_^]

so?

it is intentionally meant to be bad style

reinterpreting memory is not portable …

ok, can you help me see which cases this will not work on?

i have an output before the thread an afterwards and a usleep() in the threat. just for testing but it executes usleep and waits with the output

You're not doing io in any other thread (at the time), are you?

"pthread_create creates a new thread of control that executes concurrently with the calling thread.", so, yes, it should do this

And you do flush stdout?

what are the alignment requirements of a char **?

the only case I can think of is if char is less than a byte

char = byte, by definition

basically I'm taking sizeof(char**) * 9999
in input

yes i do

You have to synchronize access to any given i/o stream. The functions aren't necessarily threadsafe.

sorry, I know I'm not explaining this well :P

(Well, that depends on your exact system. Sometimes they are. Er, can you make a testcase and rafb it?)

Baughn via mutexes?
i'll try that first and come back afterwards. thank you for your help with that probably beginner question

I mean, no matter what the size of the pointer, it should take enough memory, right?

if you're not sure about this you better don't use such code
it might work, it might break, it might open security holes

well, if you multiply by the size of the object into a vector of universally aligned bytes, then it will be safe.
unfortunately, a local char array isn't required to be universally aligned.
use malloc

ok, I can do that instead
It's just an obfuscation project, so it doesn't matter if there are holes or not
I'd just like it to work in as many places as possible

Figs what are you asked to do ?

is there even any way to get something malloc-aligned without calling malloc again?

'^\\!%?#!(=?$&['!~('(@${#%/}.!~?~?{,+!%,@~&|,;$-#{'^'("}/*,*").~"*|#&}}"^,|-=/`?*~-/+-'^'(]"${`}#,/\')%!??|\'-"{"?#},|?},;-:')#~_&]=?

(or realloc or calloc)

not asked to do anything; it's just for fun.

Figs what are you trying to do ?

what is "malloc-aligned"?

I'm rewriting my brainf*ck interpreter

aligned in such a way that I can place any structure there and it will be aligned properly

ok

I say malloc-aligned because malloc returns such a poiner

malloc returns a pointer to a piece of memory
you can place any structure inside, if the memory is large enough

but at the beginning

the term is 'universally aligned'

maybe union { struct foo foo; struct bar bar; struct baz baz; … } is an option for you?

malloc always aligns, if it even succeeds. Always. As Z said.

a union is only required to be aligned for its member types.

that works if you know what structures there are in advance

the block it returns a pointer to is just_a_block_of_memory

but then I have to bring all of them in the same file

if you don't know you don't know the size of the largest structure and cannot malloc enough memory for it

say I'd like to allocate stuctures in a large buffer continuously
by having a pointer after which the part of the buffer is free
for this, I first have to increment the pointer to pad for alignment with the structure

and how large is this buffer?

then check with sizeof and the end of the buffer if it's large enough

increment it by sizeof(struct)

then I don't need universal alignment, right, only alignment to that struct
hmm

sizeof(struct { char x; }} is 4 on my system

so how do I align for just a given struct?

align what?

allocate space for various different types of structures in a large buffer
there can be gaps between the structures for alignment

whoops, it's 1.. strange

non-portably

b_jonas a compiler pad as much as needed to get a struct aligned

you know that the end of a struct is aligned correctly for the start of that struct

if it's an array of the same structs, it does, but it would be different structs
same

b_jonas what do you mean ?

ok, I think I asked my question in a bad way
I guess I should try again

http://rafb.net/p/2NII0833.html — so doing something like this should work properly, right?
it seems to run correctly when I try my tests on it

hello all

Figs what are you tryign to do on line 5 ?

set index_ to the start of input

but you are not changing index_ it is redundant

but I am changing index_?
otherwise what does index_ point to?

sorry I meant you are not chaning the variable "input"
changing*

?
ahh, I see what you're getting at

I mean in your code, line 5 is doing nothing… unless this is part of another code

yeah
I use it to compare against later

ah ok

stack=(char**)(&input+2*9999);
is that correct?
no… no it isn't
never mind

Hi, what should be j according to standard after int i,j; i=3; j = ++i * ++i;

I'm no expert at C, but I think that's undefined

hi all

I'm pretty sure it is undefined in C++, not sure about C99.

is there a difference between free (void *) and free (char *)?

i don't think so, free takes a void pointer so it won't have any information about it i.e. it was "cast" from a char ptr

okay
how does free know, how long the chunk of memory is?

stack=(char**)(input+2*9999); — is this correct now?

alloc can store length in bytes before pointer it returns; then free can lookup there; other implementations are possible too

ah, okay

why do you ask? just curious..

I was just curious :-)

:P

i just wrote something that stores the length at the beginning

netstring

o.O
…. and then he got a horrible idea
(me)

what idea?

structs filled with function pointers passed around in my evil nested switches

in one of my projects, we fill our structs with function pointers to be "object oriented"

yeah…
thing is…

user_t *u = new_user ();

suppose I have

new_user () just puts all the functions into the function pointers

void* foo = &funcstructA …
basically using void* to pass around functions indirectly…

just use a real function pointer

this is more evil :P

void (*foo)(void);
the most evil would be to have a char array packed with pointers
aligned to every 8 bytes
and stored in network order

I didn't do those last two bits, but I did the first one :P

actually even better, store the name and then the pointer after the null terminator

:P
that'd be good.
http://cpp.sourceforge.net/?show=39846
this isn't *really* C according to xystic
but it's close enough that you can figure out the conversion if you really want to compile it
some versions of gcc (like the one I have) don't give a rip and compile host it anyway)

2 errors detected in the compilation of "ComeauTest.c".

memset and putchar most likely

yes

and char* o comes after I do some other stuff… I don't remember if that was legal or not

Compile succeeded

you can have a lot of fun… if you like… working out my pointer math
does it run for you pippijn?
the only other person who's bothered to compile it said it gave him random output :P

yes
it does hello world

ah good

Hello World to be exact

I wrote this yesterday, I guess.
at about 4 am

;-)

this is getting to be a bad habit :P
0 am here

undefined behaviour is like that.

:P

you were up all night?

yep
two nights in a row now…

did you see the eclipse?

yes

can I use define like this eg; #define RADIUS = DIAMETER / 2

well, yes and no ;-P

do it like this: #define RADIUS (DIAMETER/2)

and will RADIUS be DIAMETER / 2 evaluated ?

oh… if that does what I think it does….

that would do *soomething*, but not what you want

yeah, and then before your program is compiled, it will replace DIAMETER with whatever its defined as

the longest wake session for me was 5 days
and I wasn't even coding all the time

and then replace RADIUS with (the number of diameter/2) /literally/

I can't stay up for more than 2 days without falling over

ok, I only want to do the calculation once

what you said would replace "RADIUS" with "= DIAMETER / 2"

you are probably older than me

ok I see

i.e., it would be like you just typed it in everywhere you place radius

ok, then you are not

:P
I just make staying up late a bad habit so I'm always tired…

I used to do that
back when I was in high school

just know that if "RADIUS" is not evenly divisible by two, and its not a floating point, you will lose some info
e.g., 3/2 = 1 (in C)

I could get away with little sleep then
at university, it's a little more difficult and I need sleep :-)

:P

so how should I do it, so that it will do the division once, and keep it as a float for later?
I dont want to use division as this is for a microcontroller and it is a very expensive calculation

do RADIUS / 2.0 iirc, people in here will know
well, if you're radius is known

this is an example

just calculate it by hand and hardcore it

please don't hardcore things here.

#define DIAMETER 5 \ #define RADIUS 2.5

did they add const to C99 or is it just a gcc extension?
o_O
"C99 also allows the static specifier to be placed within the brackets of an array declaration immediately preceding the expression specifying the size of the array. The presence of such a specifer indicates that the array is composed of at least the number of contiguous elements indicated by
the size expression."

is that correct?
or is this site wrong?
like, char s[static 10] will be contiguous

interesting

arrays are always contiguous

:blink: then what was wrong with my char foo[9999*(2+sizeof(char**))]?

a l i g n m e n t.
well, there's nothing wrong with that definition
it was what you were doing with that array afterward that was brken.

is there a standard way of making a 2D array?
er, dynamically allocating

char *array[] ?

how to find out whether a machine's stack grows up or down in memory ?

oh you mean allocating it at once?
I don't think so

Now I get it.

depends on if all arrays in the array have an equal size

yeah something weird like char **a = 2dalloc(rows, cols, cellsize)
that could be accessed using a[row][col]

I don't think so
you can write it :-)

system dependent

hi

i love it when you call me big poppavic

o.o

Have you learned about sequence points and undefined behaviour yet?

sequence points?
I've known about undefined behavior for a while, but I still run into it occasionally when I'm not thinking :P

Back to your book you go.

or not thinking the right way :P
actually, I've never heard the term "Sequence point" used anywhere.
wikipedia's got it though

without sequence points, you won't understand C's evaluation model.
what's the difference between i++ and ++i?

whether the incrementation happens before or after the rest of the computation

wrong
there is only one difference
and that difference is that i++ returns the value of i at the previous sequence point
and ++i returns the value of i at the previous sequence point + 1

so, what should be j according to standard after int i,j; i=3; j = ++i * ++i;

there is no difference in the point at which an increment occurs
undefined

because of…

I never claimed to be an expert at C, quite the opposite

because you may not modify an object twice between the same sequence points

The standard defines a handful of sequence points. One of those is "the end of a full expression".

C++ on the other hand, I'm much better at, but that's a different way of thinking.

no, because you can't understand C++ without this, either.

only a retard would make such "optimizations"

please be civil.
the question is valid and it is important to understand why.

actually, you can understand most of C++ without ever learning this

I thought that was pretty civil

consider printf("%d %d\n", i, i++);
you can pretend to, yes

Sequence points are as much a part of C++ as they are of C; i++ + ++i is as undefined there, as it is here.

what's pretend about understanding object orientation?
or templates?
const correctness?
RAII?
exceptions?
you can even understand most of operator overloading without it

I wonder what understanding object orientation has to do with C++…

hmm…I am not sure if I ran across the term 'sequence point' in K&R. is it in there?

It's in the C and C++ standards.

quite a bit

well, I don't intend to use such "optimization". I was discusing post- and prefix forms of increment in loop environment, come up with such expression and was surprised by result gcc compiled binary gave me

ok, also the definition of it?

got curious and came to ask experts

the point to take home is that things in C happen in parallel between sequence points.

The definition is in the standard too, yes.

you can read 'parallel' as in 'undefined order' if you prefer.

ok thanks, then I really have to read it some time ;-)

"Accessing a volatile object, modifying an object, modifying a file, or calling a function that does any of those operations are all side effects,11) which are changes in the state of the execution environment. Evaluation of an expression may produce side effects. At certain specified points in
the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall ha

cut off

At certain specified points in the execution sequence called sequence points, all side effects of previous evaluations shall be complete and no side effects of subsequent evaluations shall have taken place."

ok, thank you, have to think about this a bit probably. ;-)

The sequence points, are listed in Annex C.

in which standard?

1) The call to a function, after the arguments have been evaluated. 4) Immediately before a function returns. 3) The end of a full declarator… (sample listing, for a full one, see the standard).

?

C99. In C++ they are listed elsewhere.

ok

(Mostly in 1.9 Program execution in C++03).

do they actually use the term outside the standards much?
You'd think I'd have run into it by now…

Most compilers today still don't fully supports C99
which is weird since it's almost 10 years old

Irrelevant to the issue of sequence points, because they exist in C89/C90 as well.
Compiler vendors are like that.

yeah but even free like GCC

there has been underwhelming demand

yeah but still…would be nice if they started to default to C99 isntead of C89
uyeah but still…would be nice if they started to default to C99 isntead of C89/u
they should make a C08 which is basically C99 without all stuff that noone bothers to implement

heh

I find 11 mentions of sequence points throughout the C++ standard. *shrug*

you mean the draft?

no

which version of the standard?

03
sorry, my bad, 12 mentions
counted wrong.

right
I have 12 too :-)

interestingly, the word 'class' has 6110 mentions :P

hello. where can i buy a large amounts of insecure proxies? I need 500 daily

fun

##linux

Zhivago thank you, they were helpful

welcome.

xystic, how old are you?

mh. how can execute a command and get what that commands prints on stdout? it seems to me not system neither exec have this feature
of course, I would be interested in a "blocking" execution

popen, and you get it in stdin not stdout
actually no, you get it in FILE * popen returns

ok popen is the key… let me see

you can read program's stdout and write to program's stdin

*sigh* the more I learn of C/C++ the more I question my sanity.

:x

There are advantages to learning low level programming languages like C.

finishim, I thnk I can either read OR write
depending on popen's second parameter

Oh, I'm aware of that :P
it's just the particular choice of C++, then C…

well, then do C++

I'm quite familiar with C++
Obviously not all the stuff that came out of C
what I mean is, I was going through the C++ standard, and came across :
and )

:-D
what's that?

alesan you can do both, see fopen for flags they are the same
rw I think?

I've seen them before, but I forgot about them
alternates for [ and ]

anyone know about gordon bell's taxonomy of distributed systmes by any chance?

really?
wow

char foo:99; compiles.

is that used like the access operator?

at least when I tried it in gcc

wow..

`
digraphs

yeah

Figs what does that do

what does what do?

char foo:99;

char foo[99];

declare a char array with 99 elements

that works in C too I think

yeah

for systems that don't have [ ] characters

hi

Hey, whats up, pragma_

Or keyboards that don't have them.

c++ has and and or as keywords

iso646.h

what if you don't have

die

what kind of keyboard are you using that doesn't have

then you can't include stuff

pippijn exactly. they should have thought of that

find graph

ddd digraph trigraph windows

then you use rxvt-unicode and press ctrl+shift+3e
err, 3c
3e is for

windows

windows is a thirty-two bit extension and graphical shell to a sixteen-bit patch to an eight-bit operating system originally coded for a four-bit microprocessor which was written by a two-bit company that can't stand one bit of competition.

what bothers me I guess is that char foo[99; compiles.

It should.
pwned in obfusciation contests.

you can bet I'll be using it ^_^

trigraph

trigraph is a three character sequence beginning with two question marks, intended to make using c possible on systems where the usual punctuators are missing, typically from keyboards. these sequence is replaced during phase 1 of translation and takes place even within quoted
strings.

now if I can find a way to use ternary operators I'm all set…

change trigraph s/e is/es are/

trigraph

trigraph is a three character sequence beginning with two question marks, intended to make using c possible on systems where the usual punctuators are missing, typically from keyboards. these sequence is replaced during phase 1 of translation and takes place even within quoted
strings.

utrigraph is a three character sequence beginning with two question marks, intended to make using c possible on systems where the usual punctuators are missing, typically from keyboards. these sequence is replaced during phase 1 of translation and takes place even within quoted strings./u

didn't work

1 :"darn:"]? puts("Hello.") : puts("Goodbye");

have fun with that one. I'm going to bed.

Yeah, candide seems to be in need of a good lubing up.

thanks a lot!

Good morning all. I'm going to bed.
nice chattin'

sneaky lil' recursive string-rebuilder ;-)

?
It must be so sneaky that I didn't even see it.

welcome

just finished it.. I took a page from Z comments and snippets

Oh, I thought you were referring to Figs's crap.

no, that's just crap

Well, he calls it crap.

NO COMMIES
N N
O XX XXXXXX O
XX XX
J XXXXXXXXXX F

hi

lo

is anywhere specified how readdir() is supposed to work when as directory contents changes?

Um, the same way?

Manny, if you can't find any info on that, well .. undefined behavior

I doubt readdir is aware of a change while you are reading entries - particularly if you are past the entry

hello, what is the easiest way in C to check whether the first 6 chars of a 2 character arrays match?

Manny, no make sure, verify that in the posix standard doc

yeah, but I can't find any info how it deals with unread directories
thanks

strncmp, I'd suspect - is your apropos broken?

Does file locking apply to directories as well?

oh…suicide attack…

well, a dir is just another form of file.. But, don't they use a DIR* ?

"If a file is removed from or added to the directory after the most recent call to opendir() or rewinddir(), whether a subsequent call to readdir() returns an entry for that file is unspecified."
"An error or signal indicating that a directory has changed while open was considered but rejected."

good.

Many, ah, a lovely pita

hrm this is a bit tricky. I'm trying to write an in-memory thumbnail cache, with out-of-main-thread readdir() and merging with uncached entries produced from the main thread while the worker thread has been reading, but this really makes this impossible.

Manny, what are you doing exactly? Maybe there's some way around.
Manny, you might want to consider using a virtual filesystem lib or something in that direction

it's a level below. Even if I had a VFS library, it would somehow rely on the POSIX semantics.

Manny, of course. But you only had a single file to take care of.

pardon?

Manny, a virtual filesystem that uses a single image-file as a backing-store
Not a "unix vfs"

I don't see the point. It's an in-memory cache for the ~/.thumbnails folder as specified on xdg
s^folder^directory^

hm ..

thanks for your constructive proposals, I'm giving up now

I can't see any chance for it at all, unless: 1) you get events to handle or 2) the "handler" is the only interface to the dirs/files.
(the second case would be like an ftp-server)

well. the "in-memory" cache is actually trivially create by mounting a RAMDISK in ~/.thumbs
cramfs or so on linux

what a great idea!
to make it work like the current cache, it would have to 1) always cache the directory structure, including file attributes 2) be on-demand wrt contents (i.e. only cache the requested files as they are requested)

which idea? man, I am so snarfled today..

to do caching using sam RAM FS
and just throw that part out of my lib

Ok.. I can't recall the last time I used a ramdisk

well this may not be the appropriate FS, as I said it would have to be a bit more tricky

I am making a C program that uses dlopen(). It is the first time I have used dlopen().
/home/andrew/oasys/src/.libs/lt-oasys: symbol lookup error: src/algebra/.libs/libalgebra.so: undefined symbol: swap_node_children
^^ That is the error I get.
The main program has swap_node_children() defined, and the module that I am creating (libalgebra.so) needs it
Anyone have any ideas of what to do?

you can define a macro with another macro, right? (e.g. #define FOO ; #define BLAH FOO)

jroes, Yes

cool, thanks

Err, wait, what do you mean?

looked like my syntax highlighting is off, wanted to make sure

That should work

#define FOO "hi" #define BLAH FOO then any occurrence of BLAH should be replaced with "hi"

If I later type BLAH, it will be ;
yeah
That is correct

sorry, I was trying to use ; as a separator
cool, thanks

lalal
good evening

tombee, hey, how's C comming?
tombee, **coming
tombee, settle on a linked list implementation yet?

someone here?

Hihi

many folks are "here"

im starting on my journey to learn C programming and when writing code im using the void main () in my code but im getting compile errors but when i take out void and leave the main() then the code works fine does this have to do with a version of C that im using or what

hey, x = rand()%9; what would the range of x be?

im writing the from a freebsd machine

0-8

no wonder…

int main(int argc, char **argv) { return 0; }

ok

or int main(void) { … }

main () w/o void is K&R C

ok
yeah

the problem is that main mustn't be void.

Some compilers support it, but it is quite old

thats the book that i have

if you leave it out, it defaults to int

ok

I would use int main (void) if you don't have any args and int main (int argc, char **argv) w/ args
int main (argc, char *argv[]) is also ok

ok ill give that a try

that's the same as omitting the return type of main itself

are there any sites that are dedicated to c programming im looking to play around with some C code

!books

books is http://www.iso-9899.info/wiki/Books

http://rafb.net/p/pr9lKv91.html

which you can't

K&R assumes int if you just use main ()

not recommended

entirely stupid thing to do, though

err, int main (int argc, char *argv[])
PoppaVic, Yep yep

(1) some libraries override your main (such as SDL), so if you use int main() you get weird compile errors

iirc, c99 won't assume

sorry?

iand c99 doesnt support default int anymore.

SDL definetly does not do that

I was speaking about C89

oops
it was arke who said that

But yeah, I use int main (int argc, char **argv)

it was never a smart thing to do

SDL does not do that

and, it became obvious when folks would call a func w/o a proto and shit screamed and died ;-)

yes it does.

i'm pretty sure it does not
i've using it quite a lot

I'm absolutely certain it does.

*used

Actually, you can redefine main()

hold on, I'll find it…

And make it accept whatever you want
But it is kind of pointless

nope

(Regular C allows this, C++ does not)

thanx wulf

http://www.google.com/codesearch?hl=en&q=+SDL_main.h+show:9yM8QAUfHco:uaAQzixd8v4:2PBU3g9s0-w&sa=N&cd=1&ct=rc&cs_p=http://freshmeat.net/redir/scourge/46815/url_tgz/scourge-0.18.src.tar.gz&cs_f=scourge/xcode10.4/Frameworks/SDL.framework/Versions/A/Headers/SDL_main.h#a0

PoppaVic, I made an example somewhere, let me find it

proof is there.

int main( int argc, char *argv[], params_t *params ) — I used that
For a proof of concept program
And it worked

btw, I just saw - it only does this on windows and mac
but it still does it.

I could then call main() from the program again

so stfu
i don't care about either of those platforms

PoppaVic, Of course, such a thing is quite pointless, but C allows it

who fucking cares? I said it does, you said it doesn't, I established it does under the two most common platforms.

Please be civil.
hehe

i've used sdl quite a bit
and i've never used that SDL_main thing

printf("%d", ++i + ++i + i++ + i); ?

always worked well

soyou've only been using it under linux and bsd. great. how am I supposed to know?
….
again, it's transparent from the programer

alanhaggai, I believe that is undefined

#define main SDL_main

alanhaggai, But I could be wrong

Griswold_, i = 0, and I am getting the output as 8. Why is it so?

psykon, you are wrong. SDL redefines main

umm, the 3rd arg potential to main() is char **envp

Please learn to be civil in future, especially when you're spouting incorrect facts

(and folks need to stop that [] crap in args)

just because it doesn't do it on your platform doesn't mean it doesn't do it at all.
indeed, i much prefer char** as well
although it's technically the saem

Actually it does it on every platform I've used it on, arke and psykon, which includes Windows and Linux

I know it's technically legit, but it just confuses folks whom can't seem to understand you can /not/ pass arrays.

alanhaggai, Try ++i, you should get 1

in the SDL_main.h I posted above, it does so on windows and macos. then again, it might differ with different versions.

Ok Griswold_

Then try ++i + i to see if it your compile evaluate from left to right or from right to left
In any case, I would recommend not doing that because iirc it is undefined C, and it looks ugly / is hard to understand.
IIRC, GCC is right to left, MSVC is left to right, but my memory could be wrong on that one

Perhaps I'm mistaken about it redefining main on linux then - I thought it did. Either way, it certainly redefines it on at least 2 platforms

Griswold_, ++i + i = 2 for my compiler.

Ok, that would be left to right (assuming i = 0 before the statement)

Griswold_, I am using gcc.

on the two biggest platforms no less.

Ahh, GCC is left to right and MSVC is right to left then I believe. I think I remember them being backwards

arke yes. Notice how quiet psykon has went all of a sudden

Griswold_, but still I am not getting why ++i + ++i + i++ + i is output as 8 :/

"hmmm dingers"

It is ugly, I know. But just testing the way it is working.

yep, it amuses me.

alanhaggai, it's called undefined behaviour

Cin, haha. Really, is it so?

++i + ++i + i++ + i = 1 + ++i + i++ + i = 1 + 2 + i++ + i = 1 + 2 + 2 + 3 = 8

alanhaggai, yes

But yes, it is undefined!!

I don't understand all the newbie-fascination with ++

So don't use it

Ok.
Thank you

np
int i = 0;
(i++) == 0, (++i) = 1
*==1

I got it now.

The prefix version adds first, then makes the statement that value, the postfix makes the statement the value of i, then adds one to i
ok

I am just studying C, any good tutorials that you would recommend?

GNU C Tutorial

!books

1 sec, let me find a link

books is http://www.iso-9899.info/wiki/Books

http://www.crasseux.com/books/ctutorial/

use a book. Online tutorials are usually just asides, addendum, features, clarifications, etc - or wrong.

Thank you Griswold_ and candide
Ok PoppaVic

is there a way to reinitialize a character array? I want to do something like this: char temp[5]="Hello"; temp = "fooba";

hrm

nerve, no

http://beej.us/guide/bgc/

wizo !!

nerve, maybe strcpy =p

the 'hello' part was fine

Cin!

K&R's "C Programming" is a good book. The C in it is, well, K&R C, so you will have to update your syntax a bit afterwards, but it is pretty good.
uK&R's "C Programming" is a good book. The C in it is, well, K&R C, so you will have to update your syntax a bit afterwards, but it is pretty good./u

strcpy is the alternative

Today, I was trying out a program that accepts user input (character-wise), atleast that is what I tried to do.

you don't need to give the size on initialization

wizo, oh man i thought this dialict didn't support strcpy

char temp[] = "Hallo";

But, it just accepts all of it and not character-wise.

thanks for the tip, i'll keep that in mind

Any alternative to getch in gcc?

what is getch?

char temp[5]; … strcpy(temp,"hello");

alanhaggai, what are you trying accomplish?

Um… getc() mebbe?

line-buffered

wizo, Like, enter some text and quit atonce on entering a character like ~

ha. buffering

PoppaVic, that wouldnt be a string would it? there wouldnt be space for the

well, it was his own '5' ;-)
right, though: no , so it's not useful as a "string"

hehe yea

and, I'd bet the strcpy clobbers someone innocent ;-)

they recomment strncpy or something?
recommend*

he'd have the same lack-issue, just no-clobbering
they "recommend" folks allow for - all the time ;-)

haha yea

there is strlcpy that the bsd guys use
what's the difference to it?

never seen/used it
hmm

i'm off, g'night guys

bye

hi
what are some common compilers used on Windows besides MSVC++

hohum, There are GCC ports

mingw, sometimes used with the dev-c++ IDE

And Borland C++
Mingw/Dev-C++ is basically GCC

http://www.smorgasbordet.com/pellesc/index.htm
Pelles C is C99 compiler, with great IDE and debugger

http://www.digitalmars.com/
a href="http://www.digitalmars.com/"http://www.digitalmars.com//a

stay well, folks.. I'm calling it a knight.
\quit

printf("A letra %s apareceu %d vezes", vogais[i], &maior); there is a mistake here.. what is it ?

what type of var is vogais?
char **?

char vogais[5]={'a','e','i','o','u'};

you're formatting &maior as %d

yes, maior = int

Why & on maior? & is for pointers.

hm

if maior's an int, then drop the &

ah yes, i use &maior on scanf() for example..
& refers to an address.. right ?

ye
s

sry ;(
sux, i'm getting crash program yet..
and the problem still here printf("A letra %s apareceu %d vezes", vogais[i], maior);

format vogais[i] as %c, because it's character. It's not string. %s is for strings.

ah ye

Hrm…

I'll hrm you in a minute

char *foo(void) { static hosting char buffer[10]; return buffer; } == gcc doesn't complain of lack of const

where should the const be?

Um..
const char *foo(void) { static char buffer[10]; return buffer; }
even

there should be no const

oh

http://pastebin.com/d5b7b9baa == the actual code in question

I mean to say that it is not necessary to have a const
do you know what the static before your function definition means ?

yup

what ?

Don't make the function visible beyond this compile host unit (namely, this .c file)

ok good

But… I've just realised, it's fine… gaining a const is always OK…
I was too busy thinking about arguments passed in to functions, I forgot about return values

unles you want to modify it

I was just going to ask what's wrong about returning a const

I'm not returning a const. I'm returning a const*. That's differenrt
Anyway; the pastebin should explain its usage

LeoNerd, pardon my ignorance, how is it different? You can't change this pointer's value - it's an array, it's always a left value

hello my niggers

Hi, I'm a C programmer since 2000, but i didn't understood that "if" command very well, can someone help me?

const char *foo; == foo is a (mutable) pointer to a const char.

just ask your question please

It's the char it points at that's const, not the pointer itself

if (expression)
{ instructions }

what do you mean by "expression"?

b )

{ printf (" ",);
}

dude

he's trolling

yeah

if (ab) {printf (kennyd`s eatin` s hit",);}

stands for "less than" right?

Parse error

oh

right

however why would you use const char * when it is already in read-only memory ?

wait
no
it's "more than"

To indicate to the caller… "don't modify this value"

but he can't

But the compiler can't know that

ok I see

The compiler won't let you lose a const, once you have it
The compiler won't let you modify a const
const char *foo = some_func(); foo[0] = 10; == compile hosting throws error

yes correct :-)

char *foo = some_func_that_returns_const(); == compiler throws error

I heard that the compiler will let you lose a const

shouldn't the warning come when the caller tried to assign the result of a const to a non-const, or modify a const? in which case your example is ok

SamB, yeah

but that you'd better not get it modified as a result

Yes; my example is fine… I wasn't thinking right
Incidentally, I want more markers and semantic analysis
allocated void *malloc(size_t size);

see 'restrict' in C99

Static analysis of where 'allocated' pointers go, would be nice
malloc() being their only source, free() being their only drain

is there some gcc __attribute__ to omit frame pointer (i.e. prologue/epilogue) for specific function in source file?

naked, I believe

ARM, AVR, C4x and IP2K arch.

Quite possible

so no naked for intel

hi is there a libraly like SDL for C that eats less memory?

lubos, what do you use SDL for?
*to do

Hi, what free C compilers are there?

gcc?

im looking for C libraly that handles input, window creation,timers, is portable and can draw pixel onto screen

for windows

djgpp
mingw?
cygwin
visual c express

lubos, glut and openGL? :-)

legis, look at http://www.thefreecountry.com/compilers/cpp.shtml
btw, google rocks.

LeoNerd, if const char *blah is a pointer to a constant char, then how would one write a declaration of a constant pointer to a char? I'm not arguing - I'm curious. K&R says that const applies to the declaration of the variable, and for me const char *blah truly looks like a non-mutable
pointer..

ok, thanks.

const char * const foo;

hm, i will give it a try, thx very much

http://en.wikipedia.org/wiki/C_variable_types_and_declarations
^– the article I wrote to answer just such questions

you should read it backwards to get a hang of it

Never seen them stacked before Thanks, I'll meditate on that.

lubos, ever used openGL?

i need a small compiler, the ptrogram doesn't have gui.

And anyway, "const char *" is really a misnomer; should be called "char const *" …
Read it that way and it makes more sense
Anyway, I was going home
Bye all

bye

yes, but just simple drawing..i was using c++, but now i want try C

lubos, Cairo?

why you are using C?
what?

lubos, openGL only do simple drawing

http://en.wikipedia.org/wiki/Cairo_(graphics)

lubos, who said I was?

hmm, you are in C irc eh
will look at it also, thank you very much

lubos, np

you are using it?

lubos, I use C because I like to shoot at myself

No, I don't use it yet. I probably will though
IIRC Firefox and the like use it

uuuuuuh??

don't use a smiling face after an uh , it's rude

http://www.fltk.org/

hello my niggers

finishim, timeout

another one, thank you now which one to use..

fltk is c++, if you need that

lubos, if you require fast rendering, use openGL

Cairo also has hardware accel. when available.
For basic 2D stuff, either will probably work.

ooh i want C this time

For 3D, use OpenGL, for more advanced 2D, use Cairo.

what about Qt?

lubos, but if you want to use openGL, you should read "the red book"

then cairo for 2d, opengl for 3d

what i want to do is to use only drawPixel() and make everything on my own

lubos, ray tracing?

how are you my niggers

or you can use XLib, if you like low level things (and you're masochist)

in no way are we your "niggers"

lubos, If you want to create a drawing lib. "just for fun," you can use XLib, like was mentioned.

finishim, we are c-fooers

uhm? can you explain it more?
ok putting xlib as another candidate
what are these ancient games made in? like warcraft1 or prehistorik

lubos, I guess you're not then :P
maybe some direct access to the VGA?

no i dont but will read about it. direct acces? that sound cool heh

lubos, nah, it ain't cool

xlib is only for linux? :/

it is cool in the same way hemroids are cool

but its fast?

Xlib is only for X.

Agathezol, haha

put your fist up in the name of niggerhood. you are my nigger soldiers

I guess we were due another troll.

Auris-: ?

lubos, why is memory a problem?

Agathezol, I find your lack of a question disturbing.

its not really a problem..but i want to do it with fastest and minimal memory consumation way

Auris-: was questioning the comment on being due a troll, seemed to come out of nowhere.

nigger brotherhood is what it's all about
lets sing ancient nigger songs

Agathezol, really? maybe you have handy ignores set up.

finishim, Please stop using racist remarks.

xvideo is quite fast http://en.wikipedia.org/wiki/X_video_extension

Griswold_ what racist remarks, my nigger?

Auris-: ahh, i ignored the finishim guy as soon as he started talking. I'd forgotten about him :P

Anyone have admin priv.s?

nigga plz

I picked a wonderful time to join the channel didn't I.

we niggers must stick together

apparently

Any recommended source code for a C newbie to play with?

flounders, the examples in K&R

I meant aside from those.

http://lxr.linux.no/source/

Thanks.

np

lubos, what OS are you going to use then?

i am a nigger and i'm a proud nigger too. you guys should be proud as well

im using mostly windows, but have also linux installed..im now going to look at glfw and opengl and see how memory it eats

niggers are overtaking this channel

ok

soon we will outnumber you like we do in basketball and correction institutions
once niggers take over this channel will be renamed to ##x

why would you say that

you're not entertaining anybody , you're not funny , you're not informative , you're just a bored white guy

don't feed the troll

matt__, because he's a moron.

CoreEvil no white guy, i'm a nigger just like you

is there a compiler for x?

CoreEvil i'm no white guy, i'm a nigger just like you
niggers are taking over the world

go away , like leave the channel and never come back until you have something interesting to say

CoreEvil you should support your brother, nigga

finishim, you have 3 choices here. You can either (1) leave (2) stop trolling or (3) continue trolling while I go get a staff member to sort you out. Which is it?
oh, and by the way, the staff on this network tend to be extremely helpful, so choose wisely

IRBMe you will get irc pigs to beat up on a poor black man? racist
IRBMe why do you hate niggers

You chose unwisely

FINISH HIM

IRBMe, Oh, the irony of him calling you a racist.

matt__ yes hang me on a nearby tree, like in the good ol' days
i didn't expect to find so many biggots in a programming channel

do you really believe that someone actually cares about what you're saying here , I mean I wouldn't mind it if you know that you're a useless idiot who is wasting his time on IRC , but it would be really disastrous if you actually think that you're making a point or using your time wisely ,
I'm being honest here so please don't take that as an insult

CoreEvil, ignore the troll. Staff have been notified and will hopefully deal with him when somebody gets a minute

CoreEvil don't beat up on your brother, nigga. say no to black on black crime

By feeding the troll, you just encourage him to continue. Ignore is the way forward
bBy feeding the troll, you just encourage him to continue. Ignore is the way forward /b

finishim , I want you to shutup and consider what I said , please

is he a bot

a bot would be much more intelligent
I think

best burn ever

Heh, nice

why didn't someone tell me there was a circlejerk going on in ##c?

Didn't come to mind.

flounders, we used our sweat instead

the number of white supremacists in this channel is worrying
wanting to keep the black man down

How long did the staff say?

you can't ban a person because of his skin color

you could use a /ignore if he is bothering you.

finishim, so, you like mortal kombat?

Everyone was replying to him so I turned it off just so I could see what was going on.

wow, now THIS is C talk

Cin, I love MK

not much

maw, I'm making my own version of it in opengl. it has two characters. sub zero and ninja

cool, I always loved subzero
I want to buy a subzero costume

He's not saying much anyways and it's somewhat entertaining.

No Japanese school girl? :O

RobbieAB, maybe, you could send me pictures of your mam
which I could use as for sprites

that would definitely fail.

oh hello, some certain troll left their netbios port open and doesn't have a firewall

netbios still exists?:

yup
just as i thought

I thought about your mam

oh, like we can't recognise your IP, cchan_, or should I say finishim

IRBMe, RPC then?

You left your NETBIOS port open, moron

finishim, is on an open proxy

Better close it quick

cchan_ is me, testing the proxy

nigger pride world wide

i have to do what i have to do.

hack this station is masturbation

quick question.. isn't this a bug if the printf outputs 20 ?
76 strncpy(datetime, token, 20);
77 printf("%d\n", strlen(token));

you can kill me, but you can't kill the nigger revolution

that's ok, we'll settle for killing you

i have a dream

I wish bored children could think of something more productive to do

Can a symlink's target be longer than PATH_MAX?

you're an embarrassment to any community , regardless of their color , if I was a "nigger" I would have spited right in your face

i donn't think so altough i'd like such questions to be redirected to #posix

finishim, i'm getting this proxy klined if it's the last thing i do

azi`: Thanks.

CoreEvil if you were a nigger you would know better

you mean he would be stupid?

azi`, strncpy won't terminate the string if there is no within the N characters.

there we go.

Auris-: well that's what i wanted to hear

which chan did you attack?

i didnt
just a /quote names
so i'd be disconnected by "SendQ exceeded"

Ah, ok.

cchan, you do know that would only affect the connection you had and not his too, right? :P

cchan, you won't get k-lined for that

ugh

Even though they're from the same IP, they're separate connections - filling up the send Q on one doesn't affect the other

he must have just got bored :P

He just quit normally *shrug*
About 15 seconds after you did

cchan, I bet finishim is you :-)

i was going to DCC a decently high profile channel, but without much collateral damage
and no, i was just testing the proxy

yeah right

i wouldn't expect someone from france to be as racist

why not?

or to use the term 'nigger'

France invented nationalism

maw because only ustards are racist

pretty much

bhzz, nah, we got a lot here too

Europeans worked a lot of their racism off in the past century…
There are still a plenty around though.

\

:-)

I'm not trying to defend racist bastards or anything, but you should know that black culture in America seems to celebrate crime and violence.

you know ogl?

lubos, I've done some ogl, yeah

do you know if theres function for drawing pixels like drawPixel(x, y, r, g, b)?

Which leads to, inevitably, a lot of people to mistakenly believing that black people behave that way for genetic reasons, rather than cultural reasons.

Teckla, The ghetto *culture* does. The black *race* does not.

Yes, that's what I just said, didn't I?

lubos, check out POINTS

Teckla, There are blacks that don't live in the ghetto
Hence, black culture does not equal ghetto culture.

yeah they live in da hood!

lubos, but you can create an raw image and use it as a texture

Good point, please pardon my lack of accuracy, what you said it precisely what I meant.

it think that will be a lot faster

hi jengelh

Teckla, no problem. I tend to pay *very* close attention to word choice.

lubos, the redbook covers it all
lubos, chap 8 iirc

Zordon, do you realise how much your nick sounds like an alien character from star trek?

lubos, oh, you got rasters

zordon? i dont remember hearing that in startrek

In my opinion "ghetto culture" has set blacks back decades in America…unfortunately.
After decades of hard won gains, it's a shame.

this is C

azi`: You're right, sorry, consider that my last comment on the matter.

jengelh, call yourself a fan

you can continue on #philosophy perhaps

http://www.cepba.upc.es/docs/sgi_doc/SGI_Developer/books/OpenGL_PG/sgi_html/ch09.html but dont know whats faster

it's #C for Caucasian

and ##c is for the c programming language

lubos, set your projection matrix then glDrawPixels with rasterpos 0,0

http://www.quintum.com/support/xplatform/ivr_acct/cdr/cdrsrv_v1.0.3.c with visual c++ 2005 express, i do cl.exe file and i get a error saying cannot open windows.h or something like that.

something like that?

cannot open include file windows.h

that's very informative , I bow in admiration

CoreEvil, that's very witty, I slit my wrists

legis, you have to install a few libs before you can use VC++ express IIRC

i will try that, i found also this: http://rafb.net/p/VmT6dG93.html

haven't used it for years, legis

do you recommend any light compiler to build that code?

install vc 9 express beta2(orcas), it comes also with platform sdk(which contains windows.h)

lubos, that is a lot slower
lubos, don't use glBegin, use arrays

ah, deleting it from the list then

lubos, setting the color and vector for 786432 pixels got a lot function call overhead

or try this: http://msdn2.microsoft.com/en-us/library/ms235626(VS.80).aspx

thanks, checking it.

it is from Power Rangers (http://en.wikipedia.org/wiki/Power_Rangers)

ah I remember , Zordon Power Raaangeeers , right?

Yea
I watched it like a kid, because I'm so f*cked up now

neat , I tend to watch it like a grown up

Is there a cross platform way to get a very accurate time measurement?

an atomic watch?

in c

slide, not that I know of
slide, there might be a lib for it

gettimeofday

utime.h

Griswold_, time_t isn't very accurate

Yeah

hrm

slide, How accurate do you need to be?

as accurate as possible, im doing opengl animations

just use gettimeofday

just drawed some white pixels onto screen thanks for your help

can vim be setup to add context menus for when your over a variable so that you can jump to where its defined even in another file
?

lubos, np :-D

i know it can be but is there a c plugin for vim ?
besides basic highlighting

chino, You could probably write such a plug-in for Vim
Have it parse your #includes and the .c file itself, and then go to the correct spot.

there was such a plugin called railsvim that was very nice… it would be cool for c too

So go grab the source for it and make it work for C….

hi all
how can i compile two functions knowing that both have main()?
i'm using gcc

hmm?
What do you mean, "two functions?"
Two source files?

a mean the main program source and an external function

compile them separately

gcc -c -o main.o main.c
gcc -c -o other.o other.c
gcc main.o other.o
err
gcc main.o other.o -o sample
../sample
lightghost, That help?

ok,thankx
i'll give it a try

ok, let me know how it works

Hello everyone, I have a .c file with a struct definition "struct db { …. } *node; and some functions then I have a header.h file that contains this extern struct db *node; and then in a third .c file I include header.h and I do static struct db *cur_node = node; however I get an error
dereferencing pointer to incomplete type. I will post the code for you.

didn't work " multiple definitions of symbol _main"

lightghost, Can you pastebin your code?
http://rafb.net/paste
(And then give me the link)

_sin_, you have the struct in the header?

if you have twi main()s, you got basically two programs

no

i would try to link them separately?

_sin_, maybe you should move it there?

maw http://rafb.net/p/BW6X6f26.html
I will try

how? i'm learning c

lightghost, Can you please pastebin your current code?
http://rafb.net/paste (And then give me the linke)

yeah paste it..
you should also try to use ide, ide is text editor that integrates with compiler

already did

what you are using to code?

i know it would be much easier but i'm trying to learn the without usind any ides
i'm using vi
on a mac

ah, ok
so paste code

lightghost, Ok, I see you have two main()'s, which is not allowed in C.

I think I fixed it, thanks for the hint

http://rafb.net/p/Oyg7EE51.html

Which main() function do you want it to run?
Or do you want it to switch which one it runs depending on some input?

i got it from c primer plus book

Do you understand what it does?

and that book say it will work with two mains? :o

yes

Ok, so, which main() do you want to run?

maybe it's an error
the one in usehotel
it's about putting all my functions in a separte file for reusabilty

do you know how to create header files?

Delete the first one
(The first main() )

in hotel.c you mean?

sure?

how can i create my own library???

wait 1 sec

monsterior:what libraly

usehotel is the main program file

somone like a monsterior.h
something like a monsterior.h

start saving your books until you have enough to fill a building

lightghost, Delete the one with all the printf()s I would think

also put everything above second main to 'hotel.h", that book should explain it didnt it!?

heh

i think i have enough for fill a building, is something with graphics

???

monsterior, Basically, create a regular program w/o a main()
And then link it like a lib

Is there a reason why an aio_read wouldn't return a signal?

Make a header to help export your functinos

ah, thanks

And then link the lib to whatever program you wish to use it in
uAnd then link the lib to whatever program you wish to use it in/u

=?)

if that book gave you this code you showed, you should buy some better book

lubos, No joke

it's an old one got it for a buck

lightghost:i will separate it w8
so heres our main1.cpp, the first program: http://rafb.net/p/lqSZvw86.html

here's an idea, would it work if i replace word main in the second file with hotel that make's it the functions name?

heres main2.cpp, the second program: http://rafb.net/p/AjnM7×56.html
ane hotel.h: http://rafb.net/p/9EsbPl50.html
save them, compile main1.cpp and main2.cpp separately

then?

then you should have 2 exes

main1 should use main2,right?

i wonder, shouldnt be second main() called menu()?
no no

lubos, if you are compiling .cpp you are on the wrong channel.

Auris-: sorry, name in main1.c and main2.c then
just used to code in c++
try this: http://www.cprogramming.com/tutorial.html#ctutorial

thanks

get a book instead.

just tell me one thing,you can have only one main(),right?

lightghost, Yes

i love books

main() is where the computer knows where to start the program from

ok,then i think i can fix it

ok

lightghost, you can have only one of each function.

thanks

except when you know what static hosting does.

Yep.

auris:know any good books?

!books

books is http://www.iso-9899.info/wiki/Books

also known as the books section of the channel wiki, as advertised in the channel topic.

thanks for the help

You're welcome, lightghost

thanks guys you've been a big help

thanks for the beer

No problem, Auris-

hmm, what is the point of that action.. :-)

8U

i have a macro question
it seems apparent to me that if i do #define bar() foo
that using just bar without using bar() yields literally the symbol bar instead of foo

and, where comes the question?

hey
i'm starting to learn C, but have been having a few troubles

got your hello-world program running?

for some reason on http://go-beyond.org/misc/advstring.c the if statement becomes true when i=7840. my BUFSIZ is 8192

however, it seems like if I do #define PASSTHRU() ()
and then "bar PASSTHRU()"
it will evaluate to "bar()" instead of "foo" ?
what is the reason behind that exactly

your code can be overflowed, there is an off-by-one error in it, you can't fit sizeof(buf) characters in it, you need to feed fgets like this fgets(buffer, sizeof(buffer) - 1, ….), fgets will append an ''

try gcc -E to see what the preprocessor does

fax ah nice
but why does it work like that?

where is BUFSIZ defined ?

if i just write bar () on its own, it expands to foo

stdio.h
_sin_, changed that but it still isn't working
thanks for letting me know about the off by one though :-)

I know, that wasn't the asnwer to your problem.

sin, sega01, fgets() reads one less than size. so you shouldn't do sizeof(buf) - 1.

Auris-: I think fgets requires as an argument the number of characters, not bytes
the '' should be at buffer[sizeof(buffer) - 1]
it reads one less and then appends ''

what? "number of characters, not bytes"?

characters == bytes, according to the definitions provided in the C standard.

_sin_, how you would manually terminate a buffer is not the same as how fgets works.
char == byte, a character can be more than one char.

does sigmask unblock after sigwait returns?

is there anykind of championship on the internet about "who writes a code for certain purposes faster" ?
in C language.

yes

all the time ;

its usually about who writes algorithms faster though ,not who "codes" faster

do you have the website?
yes, algorithms

well C isnt that great for writing algorithms fast
its better for writing code that *executes* fast

hmm
I can write in C or C++ anyway

which is really not relevant in an algorithms competition, the academic running time in big-O is

albertmk http://acm.uva.es/problemset/ is one of them

are you still in high school?

college

oh
ACM has stuff
very hard code

cool

I dont like them, most of it is memorizing algorithms and reapplying them

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Comments are closed.


Blog Tags:

Similar posts: