--------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGN00003 Date: 12/17/97 From: NICK SHREDERS Time: 01:19am \/To: BILL BIRRELL (Read 3 times) Subj: Help ;) BB> Eek! > printf("\n %d is not between 1 and 20"); BB> What is the %d converting, Simon? I'm not sure what BB> happens when the format part doesn't have a BB> corresponding argument. With my compiler (gcc version 2.7.2.3.f.1 linux) and hardware (i486) it returns -1073743032 , although im sure it varies from implemenation to implementation. Anyone know off hand what the ANSI standard says on this? --- Maximus/2 3.01 * Origin: Homer's Hut (1:299/120) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGN00004 Date: 12/17/97 From: BOB STOUT Time: 03:29pm \/To: NORMAN DODGE (Read 2 times) Subj: ORCA/C On , Norman Dodge (1:343/133@fidonet) wrote: > Incidently I'll attempt to write up how to file for Snippets. You will > have to edit it so it will make sense. Great - it will be appreciated, I'm sure! --- QM v1.00 * Origin: MicroFirm : Down to the C in chips (1:106/2000.6) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGN00005 Date: 12/18/97 From: BOB STOUT Time: 10:54am \/To: CHRISTIAN CALONICO (Read 2 times) Subj: Program On , Christian Calonico (4:901/339.2@fidonet) wrote: > What's the program you use for sending code in diferent messages? It's called CSPLIT - the source is available in SNIPPETS. --- QM v1.00 * Origin: MicroFirm : Down to the C in chips (1:106/2000.6) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGN00006 Date: 12/16/97 From: FRANOIS DE MEY Time: 04:13am \/To: ``RICHARD CLAYPOOL`` (Read 2 times) Subj: I'm a little bit confused on something Hi coder, `C> Hi, could someone please give me a good definition of pointers? `C> Here's what I understand them to be. a pointer, forexample char *s `C> can be used to move throgh an aray of chars. for example, a pointer `C> can be used in a loop to be moved backwards and forwards in a char `C> declaration. This is the explanation which i got from someone, but `C> that doesn't sound right. I am a bit confused and would be greatful `C> if someone could give me a bit better of a definition. It seems to me `C> that I also read that a pointer pointed to a spt in memory. also, `C> what is the practical application of a pointer versis a standard cha. `C> thanx, and sorry for posting thesxe elementry questions. when U type "char c;", C will allocate U a byte. When U type "char *ptr;", C will allocate U a word, this also with int*, long* or struct*. U can, for example, type : char *cptr; int *iptr; cptr = ...; iptr = (int*)cptr; NB: If U ask a far pointer ( char far *cptr ), it will allocate a dword, this will contain seg:off of variable. Default type is near: only offset, segment is SS. If U code in assembly, imagine that in mov [bx],al al is the char and bx the pointer. A pointer just contains the location of the variable, if U type "*cptr", U will access char located at ss:[cptr]. If U type "*(cptr+1)", U will acces char just after, but it's still easier to enter "cptr[1]" NB: It's the same meaning! cptr[0] = *(cptr+0) = *cptr. Note also that, in assembly, when bx point on a word table, U have to increment bx by 2, because word are 2 bytes, but C will do that for U, if bx=iptr, iptr[1] is the same that [bx+2], then U must specify a type of pointer ( char*, int*, ... ) I hope it would light U... FeP --- Blue Wave/DOS v2.30 * Origin: Programmer's Paradise -Belgium- 32-10-813088 (2:293/2009) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGN00007 Date: 12/18/97 From: ANTHONY TIBBS Time: 07:20pm \/To: ALL (Read 2 times) Subj: Windowing system? Hello All! Disclaimer: Sorry, Auke, for the C++ - I won't post any C++ code in here. > I wrote my own text mode windowing system a while back, but a recent "project" has proven it inadaquate. I just spent the entire day attempting to re-write it, but other than crashing the system several times (corrupting the source code several times), I haven't made any progress. Does anyone have a package which: - Works under DOS - Provides FAST output (i.e. direct video output, compatible with DV) - Supports single and double borders, as well as titles, on the windows NOTE: In this project, I also need windows which have *no* borders... - Provides "shadows" on windows - Can be easily C++-ized, even if it's simply a wrapping... - Provides the following functions: Write() (write at the current position) Write (x, y) (write at x,y relative to the window) Printf() (printf at the current position) Printf (x, y) (duh) I don't need any other functions except those listed above. (This does not include things such as "SetAttribute" for setting the current colour, etc.) I don't care either way if it's portable or not - if it works under DOS, can be compiled with BC45, and can be C++-ized, I'll be happy. Kurt? You seem to do a lot with direct video output... Maybe you have something? :-) Take care, Anthony --- timEd/B8 * Origin: The Tibbs' Point - Ottawa, ON - Private (1:163/215.38) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGP00000 Date: 12/19/97 From: BOB STOUT Time: 01:39am \/To: ANTHONY TIBBS (Read 2 times) Subj: Windowing system? Anthony... I believe Greenleaf still makes such a package, although, for obvious reasons, it's not well-advertized. Call them at 800-523-9830. --- QM v1.00 * Origin: MicroFirm : Down to the C in chips (1:106/2000.6) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGP00001 Date: 11/29/97 From: BRIAN MCCLOUD Time: 06:15am \/To: STEVEN HANCOCK (Read 2 times) Subj: Small problem -> believe is \r, Ctrl-M, but maybe I'm wrong, maybe it's \n). That makes it -> quite a task to edit the file by hand adding the \0x0A (Ctrl-J) character to -> every line to make it readable on my system. Is there a utility I can use -> to automate this. I've tried a small convert program that was posted in -> this I've got a program I wrote in Pascal (though I could port it to C for this echo...) that can take CR/LF, LF/CR, CR, and LF line-end types and convert ll of them to CR/LF sequences (even if all four of those types are in a single file). It works, but I have not yet tried to optimize for speed. ((Cloud)) MauveCloud@juno.com --- PCBoard (R) v15.3/M 10 * Origin: Next time, Dial The Wrong Number! (209) 943-1880 (1:208/205) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGP00002 Date: 12/17/97 From: FRANK ADAM Time: 10:56am \/To: ``RICHARD CLAYPOOL`` (Read 2 times) Subj: I'm a little bit confused on something On Dec 12 05:26, 1997, ``Richard Claypool`` of 1:109/500 wrote: G'day ``Richard, Firstly, have you got Snippets ? It has a comprehensive tutorial on pointers. I'm pretty sure by the time you get this, Bob would've already replied telling you the same, you'd think he gets paid for it ? ;-) `C> Hi, could someone please give me a good definition of pointers? A pointer is a direct reference to a memory location. For instance if a variable resides at address 1111:1111, you can assign a pointer to point there by going.. * ptr = myvar. If myvar is an array type, this will point to the address of myvar[0], same way you can point anywhere within that array.. * ptr = &myvar[10]; Of course the "type" in most cases should match the variable's type, but sometimes one can or want to use a different type. I won't get into that just now. :-) Keep in mind this is only a pointer, to get the value from the location you need to dereference it. This is where the '*' comes in again. See below. `C> what I understand them to be. a pointer, forexample char *s can be `C> move throgh an aray of chars. for example, a pointer can be used in a `C> loop to `C> be moved backwards and forwards in a char declaration. This is the `C> explanation which i got from someone, but that doesn't sound right. I It is correct. Don't forget, allocated memory is linear. Think of your car as a pointer, having to find my house. The address is 21. Fidonet street. What do you do ? 1. Drive to 1 Fidonet street and work your way up to 21. 2. Go to the other end of the street and work your way back down to 21. If you run passed either end of the street chances are you'll crash. Ok, you have the exact location, your car is pointing at my door. You still don't know what's inside until you actually enter. This is the same with the pointer, it is at an address. To find out what's there you must derefernce it(enter the address) this is done with another '. s = address. *s = value stored at s. Well, hope this makes some sense..It did to me when i started typing. Painfully obvious that i'd better stay away from teaching jobs..:-) `C> definition. It seems to me that I also read that a pointer pointed to `C> a spt ? What's spt ? A pointer points to a memory location full stop. What may be at that location is up to your imagination.Pointer to pointer to pointer to... I have seen a post here way back where a pointer was supposedly somthing like 20-odd deep. Obviously a masochist wrote it. `C> in memory. also, what is the practical application of a pointer `C> versis a standard cha. Well, parsing through a string is one, once you grasp pointers the idea of array indexing seems like too much work (to me anyway). Take this.. char mystr[] = "Hello world"; char *s = mystr; To parse through this.. for(i=0 ;i < strlen(mystr) ;i++) putch(mystr[i]); /* RSI right there :-) */ or for(i=0; mystr[i] != '\0';i++) putch(mystr[i]); OR with the pointer while(*s) putch(*s++); I prefer to use a pointer especially on strings wherever i can, but this could be just personal preference. In most cases, modern optimizing compilers will generate pretty much the same code for both methods. Here is something silly that may help you see what's happening. ----- OUT.C begins ----- #include #include int main(void) { char *s; int key = 0; char mystr[] = "0123456789"; s = mystr; /* same as s = &mystr[0] , the index could be 2,3 whatever */ /* AMOF, To be tricky s = &mystr[strlen(mystr) / 2] will put you at middle */ printf("\nPress ',' or '.' to move. ESC to exit. "); while(key != 27) { key = getch(); /* hope you have this or similar */ switch(key) { case '.' : if(*s != '\0') s++; /* test for terminating char */ break; case ',' : if(s > mystr) s--; /* compare s to mystr's address */ break; } printf("\nmystr's address = %p, s = %p, *s = %c(value)",mystr,s,*s); if(s == mystr) printf("...First element."); else if(!*(s+1)) printf("...Last usable element."); else if(!*s) printf("...Terminator('\0')."); } return 0; } `C> thanx, and sorry for posting thesxe elementry questions. No problem, that's what the echo is for. Regards, Frank. Email: fadam@sensation.net.au. --- Msged 4.00 * Origin: The ticking point, Melbourne, Australia. (3:635/728.21) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGP00003 Date: 12/17/97 From: ROGER SCUDDER Time: 08:54pm \/To: BILL BIRRELL (Read 2 times) Subj: Help ;) Hello Bill, 15 Dec 97 07:45, Bill Birrell wrote to Roger Scudder: RS >> #define INRANGE(n,l,u) (((n)>=(l))&&((n)<=(u))) ? 1 : 0 > A question; not a criticism. I'm patently becoming senile. :-) And since you have used a smiley, I feel safe and secure that you are not attacking me personally. ;-) > All those brackets confused me. It looks like lisp, and I can't > work out why any of them except an encompassing outside pair is needed > - to protect against operator precedence contention if inside another > ()?a:b condition. :-) It's a habit I have gotten into... when writing macros, to (I admit at times, without really thinking about it) place parenthesis every where I can fit them. I think it is because of times when I have been stung by macros because I didn't use enough parenthesis that I use too many by default. Fortunately this habit is restricted to macro writing, or else I'd be making a lot of really strange looking code. I agree that this macro is difficult to read, but for me it's not much of a problem. For me a macro is a way to make code more readable (strange irony). Nothing more than a way to move ugly code out of the .c module and stuff it into a header file which in turn is stuffed into an include directory. I spend a lot more time reading and working in code modules than header files, so once I get a macro right, I won't be looking at it very often after. I appreciate your questioning me on it, though. I think I could stand to reevaluate my macro creation process. :-) Also, now having thought about it, I would like to have given that fellow something a bit better. I hate to think I may have sacred him away from macros with that beast. ;-) >What's wrong with:- > #define INRANGE(n,l,u) (nu ? 0 : 1) Since n is evaluated twice, not much can be done with it inside the macro. Add to that the fact that the operators fall low on the precedence chart which leaves even less bad things that can happen, I must say that I can't see anything wrong with your version. > Clear up the mystery for me ... I'm too decrepit to work it out. Oh, Jesus... don't try to work that out... Save your energy for the chippies at the pub! ;-) Roger ... E=Mc^5... nahhh...E=Mc^4... nahh...E=Mc^3... I give up. --- Msged 4.10 * Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA (1:273/404@fidonet) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: EGP00004 Date: 12/18/97 From: ROGER SCUDDER Time: 03:27pm \/To: BOB STOUT (Read 2 times) Subj: Help ;) 17 Dec 97 14:47, Bob Stout wrote to Bill Birrell: >> All those brackets confused me. It looks like lisp, and I can't work >> #define INRANGE(n,l,u) (nu ? 0 : 1) > It's simply a matter of good coding practice in C. Since INRANGE() is > if (INRANGE(a ^ b, Lo >>= 2, Hi <<= 3)) > IOW, there's no predicting what will happen to your clearly logical > intent once the preprocessor begins substituting expressions for > arguments and the compiler applies the rules of precendence! The > obvious solution is to *always* wrap each macro argument within > parentheses. When Bill questioned me on this I sat down and tried to come up with a use that would give unexpected results. Since the most common operators bind before the greater than and less than operators, I started thinking that I was probably over doing it. I had learned here and through practical experience that I was better off using too many parenthesis than not enough. I did allow myself to be swayed away from that rule of thumb by what I thought was a good question from Bill. I'm glad that your reply to him reinforced what I had been doing for a few years now as a good coding practice. Roger rscudder@usa.net ... 'If it ain't broke, you can probably still fix it.' - Tim Allen --- Msged 4.10 * Origin: Hodge-Podge Support BBS, Upper Darby, Pennsylvania, USA (1:273/404@fidonet)