| |
| |
| |
|
Page: 1 2
Comments:
<0> :-) <1> typedef double (*F) (double x, double y); can anyone explain this to me? what kind of type definition is this?? Is it pointer on a function or what? i just cant get it... <2> its a pointer to a function. <1> and how do i reference to this definition?? <2> http://www.newty.de/fpt/fpt.html <2> maybe that'll help you <1> ah ok thanks so far <1> yeah thanks! this was really heplful! got it now <3> hello I'm learning C.... I have a question.... if I have a number say 12345 how would I write a program to add all the digits together 1+2+3+4+5? <3> lets say printf("Enter a number\n"); then scanf(%d", &a); then what? <3> I would appriciate your advice.... <3> can anyone here help me with a simple question? <4> you should do your own homework <4> or ask a question about specific problem you are having, that we might answer <3> I'm trying to teach my self C from scratch <4> get a book
<3> if I have a number say 12345 how would I write a program to add all the digits together 1+2+3+4+5? <3> so printf("Enter a number\n"); <4> that's a homework :-P <3> scanf("%d", &a); <3> then what? <5> decompose the number, same as you would on paper. <3> how would I decompose it in C? <5> do it on paper first. <5> then c should be simple. <6> uv256: how would YOU do it? <6> (don't think about C now) <3> :) must be something with arrays... is it not? <6> well, it depends whether you treat is as a number or string :) <3> as a number <3> I want printf to print 15 <4> printf("15"); then! <3> :) come on... <3> I would I break a number the user inputs into seperate numbers? <3> I==How <6> you mean digits? <3> yes <3> sorry about my english <6> uv256: you add ones, tens, hundreds, thousands.. <3> jv: I don't get it.... <3> I'm pretty new with this <6> 12345 = 1 * 10000 + 2 * 1000 + 3 * 100 + 4 * 10 + 5 <6> uv256: c is a programming LANGUAGE <3> I"m getting a headache:) <6> uv256: that means, you express your ideas using some given set of "words" <6> uv256: first you have to realise how YOU would do it on paper <6> uv256: then the rest is easy :) <3> well on paper it is easy 1+2+3+4+5.... <3> but how do I seperate the digits from one number...? <6> but you are skipping the step I told you :) <3> oh <7> laters <8> hello <8> anyone here? <8> i allocate memory using calloc (so that it fills the memory with 0) <8> like calloc(1, buffer); <9> did you have a question? <8> and if i don't use all the length (buffer), then the free actually segvs <8> why is this? <9> no it doesn't. <8> yes it does <9> you're freeing something wrong. <8> no, coz if the buffer's full, there's no segv <9> show me the code. <8> ok <8> http://rafb.net/p/***dfZ69.html <8> try it with an html for example <10> hum,. <8> if u notice something that could be solved in a better way, tell me plz that one too <8> i'm newbie in c <9> that's some weird code. <8> ? <9> you do realise that you can't do starcat(ret, buf) when you have not allocated space to ret properly. <9> strcat() even. <8> i do strdup() for that purpose <9> strdup("") only allocates 1 byte. how will that fit anything? <8> so i should allocate the space?
<8> it works, actually <11> no, it segfaults <11> thats what you told us <11> and its wrong <8> if you comment out the free(buf); line <8> it works <11> maybe, but its still wrong <8> ok, then how should i do it? <9> it probably "works" because you, by luck, overflow into the calloced buffer. <11> and if you change *anything* in your memory layout, it may segfault again <9> you allocate space for ret. if you need more, you use realloc. <8> ok <9> also intendtin better would be nice and if you are not on windows, valgrind will help you with memory problems. <9> indenting even. <9> I have to say that the "// if" end-comments are very distracting. <8> ok <9> and that is the only thing you comment. indentation tells you where things end unless you have pages and pages of deep nesting. it would be a lot more useful to comment what the code actually intends to do. <8> well, i'll do that <8> but first i want it to work somehow <8> realloc returns with what? <9> it returns a pointer to the new memory area. to which the contents of the old one have been moved. <9> or NULL, of course. man realloc. <8> yep <8> done <8> thx <8> hmm, it works now <8> thank you <8> any other comments according to the code? <8> something which could be solved easier? <9> I haven't actually tried to understand what it is trying to do. <8> seeks a block in a file <8> beginning with begin_str, ending with end_str <9> well, yes, but the actual details are not very readable. <8> hmm <8> maybe <4> is your man page incomplete? <8> ? <9> in my opinion, doing "if (foo) bar;" on a single line usually is just confusing. and ever more so when it is used a lot, it seemingly important parts of the algorithm. <9> it=in <12> indeed, we should just do "foo && bar;" :) <9> the names of the variables could be better. "buffer" is not a good name for "length of the buffer". and "length"-variable is the length of end_str, when I would think it refers to buffer, because buffer is a "more important" object here. <9> buf. not buffer. <9> see?! :-) <8> :) <9> also, if you really want to zero out buf, as on line 84, use memset() instead. <8> with realloc, it's now unneccessary <8> or how should i write that world <8> i always forget:D <9> unnecessary. <8> thx;) <8> lol <8> so many mistakes in one sentence <8> world -> word <9> getc() does not return a char, it returns int. <9> compile with warnings on. <9> what is the point of this? (ch = getc(file)) != str[length - 1] <8> do it while the character is not equal to the last character of str <9> okay, what happens if str is "foofoo"? <8> hmm <8> you're right <8> -Wall, no warnings here <9> good. <9> also you should check if malloc/strdup/realloc/fopen succeed or not. and i is a confusing name for a char* as it is very very commonly an int. <9> 'nuff said. <8> well, i'll delete that part, anyway <10> or iterator <8> this will parse out some datas from an html table <8> **** <8> how can i detect where it drops the segv? <9> run it under a debugger. <9> or show the core file to a debugger afterwards. <13> ciao a tutti <8> /topic <8> ciao, btw:D
Return to
#c or Go to some related
logs:
#html #worldchat #worldchat #html #worldchat #worldchat catwoman- ircnet #worldchat #worldchat #worldchat
|
|