--------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3P00043 Date: 03/19/98 From: NORMAN DODGE Time: 06:02am \/To: MICHAEL STAPLETON (Read 2 times) Subj: CRC.C Hello Michael! On 03-18-98, Michael Stapleton wrote to Norman Dodge: -=> Quoting Norman Dodge to Mike Stapleton <=- MS> Hi Norman, MS> I'm glad to see that you're not missing part 9. I waited patiently for you to send it after Bob said it had gone missing from your original post in February. Well not completely patiently I e-mailed Auke for his copy which he did not have also. :-( ND> In Cfg.C: ND> enum RetVal ND> { ND> NO_PROBLEMS, ND> ERR_FOPEN, ND> ERR_MEM /* The comma after ERR_MEM is incorrect /* ND> }; /* Take the comma out not ANSI C /* MS> Since Auke originally wrote this function, you should complain to > him. :) Actually, the extra comma is allowed in ANSI C, but it was > not present in K&R1. However, the enum wasn't in K&R1 either, so > I'm surprised that your compiler supports enum, but not trailing > commas in enums. I guess it also gives the same error with: Michael! the comma mentioned above is incorrect. I know MSDOS compilers allow it but I think it is not ANSI C. Bob Stout or Auke Reitsma know about this. I have sent the above comment to both Bob and Auke. ND> While compiling CRCParam.C I got the following error message: ND> Compiling main ND> 84 argv += cfgf; ND> ^ the operation cannot be performed on operands ND> of the type given ND> 1 error found. ND> Any Idea why? MS> Sort of. :) Strictly speaking, char *argv[] is an array of pointers > to char, so one shouldn't change the value of argv. However, array > references in function parameters are converted to pointers, so argv > becomes a pointer to a pointer. It is permitted to add & subtract > an integer to any type of pointer, as long as the resulting pointer > contains an address in the original array (or one place beyond). > Statements such as: MS> strcpy(name, *++argv); > pname = *++argv; > num = atoi(*argv++); MS> are fairly common in many C programs, and they are not much > different to my argv += cfgf; Well Michael thank you very much. :) I tried the main function both ways. int main (int argc, char *argv[]) this does not work with your source declaring cfgf as an int. However a strange event occurred when I changed to int main (int argc, char**argv). No more compiler error and everything works just fine. I'm not sure what I learned but it is indeed interesting. I hope I don't forget in the future. :) Norman * 2qwk! 2.04 * --- FLAME v1.1 * Origin: TechAlliance BBS Renton Wa. 206-277-6070 (1:343/133) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3P00044 Date: 03/19/98 From: DARIN MCBRIDE Time: 07:31pm \/To: ADAM MAJER (Read 2 times) Subj: atoi(const char *s) SL>int main(void) SL> { SL> char *sTemp; SL> int iTemp; AM> sTemp = (char*)malloc(sizeof(char)*256); <- enough space for 256 digits! Space for 255 plus the nul. However... Rather a bit of overkill since 16-bit ints can only have 5 bytes (plus the nul) = 6. ;-) SL> printf("Enter a number: "); SL> scanf("%s", sTemp); AM> NULL pointer!!!!! Causes lot's of run-time errors. You must allocate the AM> memory before using it. Nope NOT NULL pointer!!!! _RANDOM_ pointer. :-) --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3P00045 Date: 03/19/98 From: DARIN MCBRIDE Time: 07:33pm \/To: TOM TORFS (Read 2 times) Subj: atoi(const char *s) TT> Darin McBride wrote in a message to Simon Law: DM> char* sTemp = malloc(TEMP_LEN) * sizeof(char)); /* DM> Woops - make that "malloc(TEMP_LEN * sizeof(char))" - had an extra DM> parenthesis there. :-) TT> Even easier is to make that malloc(TEMP_LEN), as sizeof(char)==1. Tom, I never do that. I like specifying the sizeof in all cases - I find it much more consistant. :-) --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3Q00000 Date: 03/19/98 From: ANTHONY TIBBS Time: 11:03am \/To: BRIAN MCCLOUD (Read 2 times) Subj: Re: Pascal <-> C/C++ AT>Is there any easy way to combine C/C++ .OBJ files with TP7 .TPU files AT>to produce an executable? BM> I'm not certain I'd call it easy, but it can be done. In a pascal BM> file, you'd need to use a {$L ...} Yes, I know about that. AT>If so, which language has to have the "main" program in it, etc.? Can AT>they share variables? BM> C (and most extensions/expansions thereof) require a "main" function BM> to start the program. Both languages can share functions/procedures, BM> but I'm not sure about variables. Also remember that the C compiler BM> will add an underline to the beginning of each identifier used within BM> the program. If the C routines use any standard functions, you may BM> also have to tell turbo pascal to link the library file. This is the main problem. The "_" isn't a problem, but linking in the library file is. TPC doesn't know what a library file is, and complains "unit too large". As for "both languages can share functions"... What prototype do I use in C to call a Pascal procedure? Take care, Anthony Tibbs ... Backup not found: (A)bort (R)etry (S)lap nearest innocent bystander. --- Blue Wave/DOS v2.30 [NR] * Origin: The Tibbs' Point - Ottawa, ON, Canada - Pvt (1:163/215.38) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3R00000 Date: 03/21/98 From: KURT KUZBA Time: 01:30am \/To: ERICH BRAENTNER (Read 2 times) Subj: Running clock EB> I am wondering about how I would create a running clock in EB> my program. Could someone please try to help me with this? This program places a time and date clock at the upper right corner of the screen when run. You can use the information it uses to produce other displays as well. Whatever process you are in will have to accomodate the update process in order to keep it current while other processes are being executed, or an ISR that performs these tasks will have to be programmed. /*_|_| TIMEDATE.C PUBLIC DOMAIN Kurt Kuzba 1/10/97 _|_|_| Simple clock routine for C. */ #include #include #include int main(void) { time_t Time = time(&Time); char Time_Date[26], display[32]; int dsp; do { Time = time(&Time); sprintf(Time_Date, "%s", ctime(&Time)); Time_Date[24] = '\0'; sprintf(display, " [ %s ] ", Time_Date); dsp = 0; while(display[dsp]) { *((unsigned short far*)0xb8000064 + dsp) = (((7 << 4) + 1) << 8) + (255 & display[dsp]); dsp++; } } while(!kbhit()); while(kbhit()) getch(); return 0; } /*_|_| end TIMEDATE.C */ > ] Uh-oh... No more treats. Time to learn some new tricks...... --- * Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3R00001 Date: 03/20/98 From: DARIN MCBRIDE Time: 06:43pm \/To: ROGER SCUDDER (Read 2 times) Subj: atoi(const char *s) DM>> #define _STR(x) #x DM>> #define STR(x) _STR(x) SL>> All right, you've gone and lost me here. Please explain SL>> those two previous #defines... DM> Those #defines are in snippets... with an explanation, I believe. :-) RS> What? You use it but you don't understand it? ;-) I understand it, but didn't have the gumption to do the explanation myself... :-) RS> Please try to be a little more helpful. grep "_STR(" *.* RS> returns nothing, so you must have changed it. What file is RS> this in? *I* use STR. Snippets uses "add_quotes". In stringiz.h, however it only has examples, not any actual explanation... perhaps I should find the gumption to fix that. ;-) --- * Origin: Tanktalus' Tower BBS (1:250/102) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3R00002 Date: 03/20/98 From: RON BASS Time: 08:30am \/To: BOB STOUT (Read 2 times) Subj: Re: Avoid disaster BS> On , Auke Reitsma (2:281/400.20@fidonet) wrote: RS> Given the topic of the discussion, wouldn't T.S. Elliot be a better RS> example? ;-) > He's that author who never capitalized anything? BS> bingo! ahem. that was e.e. cummings, surely! -Ron (ron-bass@ti.com) --- EZPoint V2.2 * Origin: There's a point here, somewhere... (1:128/13.3) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3R00003 Date: 03/20/98 From: FRANK SCHMID Time: 12:30pm \/To: JOHN SPENCE (Read 2 times) Subj: Re: difference Hello John, > Could someone elaborate on the difference on using -> instead . when using > them in a struct? thanks '->' is used with pointer dereferencing, i.e. if you have a pointer to a struct "mystruct" you can access the elements by using pmystruct->element. If you have an instance of the struct itself you have to use '.' (mystruct.element). So you can replace pmystruct->element with (*pmystruct).element Greetings Frank --- XPoint * Origin: Ihr da OHM, macht WATT Ihr VOLT ! (2:245/6837.11) --------------- FIDO MESSAGE AREA==> TOPIC: 239 C LANGUAGE Ref: F3R00004 Date: 03/18/98 From: AUKE REITSMA Time: 09:43pm \/To: MICHAEL STAPLETON (Read 2 times) Subj: CRC.C Hi Michael, On 08 Mar 98, 00:38, you wrote to Norman Dodge ND>> In Cfg.C: ND>> enum RetVal ND>> { ND>> NO_PROBLEMS, ND>> ERR_FOPEN, ND>> ERR_MEM /* The comma after ERR_MEM is incorrect /* ND>> }; /* Take the comma out not ANSI C /* MS> Since Auke originally wrote this function, you should complain to MS> him. :) Actually, the extra comma is allowed in ANSI C, but it MS> was not present in K&R1. However, the enum wasn't in K&R1 You and Norman can complain all you want ... ;-) But the reason I put it in in the first place was that during development I always fiddle around with things like that. And if the comma is missing there will be problems. As it is allowed by ANSI/ISO -- and none of my compilers have a problem with it -- I never bother to remove it when it is done. Greetings from _____ /_|__| Auke Reitsma, Delft, The Netherlands. / | \ -------------------------------------- --- GEcho 1.00 * Origin: Home by the C (Auke.Reitsma@net.hcc.nl) (2:281/400.20)