home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14752 < prev    next >
Encoding:
Text File  |  1992-08-30  |  1.7 KB  |  46 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!pageworks.com!world!siegel
  3. From: siegel@world.std.com (Rich Siegel)
  4. Subject: Re: Inconsistantcy in Think C
  5. Message-ID: <Btt4v5.Gv7@world.std.com>
  6. Organization: GCC Technologies
  7. References: <1992Aug30.091804.1@acad2.alaska.edu>
  8. Date: Sun, 30 Aug 1992 17:35:28 GMT
  9. Lines: 35
  10.  
  11. In article <1992Aug30.091804.1@acad2.alaska.edu> asmah@acad2.alaska.edu writes:
  12. >I have run into some very strange problems working with Think C 5.0 lately and 
  13. >would like to know if anybody know's what is causing them.  Here is one I can 
  14. >easily define.
  15. >
  16. >I have a sprintf() statement which doesn't work the first time through, but
  17. >works during a second time.  As far as I can tell, all the variables are
  18. >identical during both passes.  This is what it looks like.
  19. >
  20. >CharsHandle  input;
  21. >TEHandle TEFields[20];
  22. >
  23. >input = TEGetText(TEFields[0]);
  24. >sprintf((**ARH.c_employee).last_name,"%.*s",(**TEFields[0]).teLength,(**input));
  25. >return 1;
  26. >
  27.  
  28. If your ANSI library is in a different segment than the routine with
  29. the printf, then your call to printf() is causing a segment load,
  30. which in turn will cause the handles (**ARH.c_employee) and (**input)
  31. and (**TEFields[0]) to move. The best way to solve this problem is to
  32. lock the handles before calling sprintf(), or place the ANSI library
  33. in the same segment as the code that calls into it, to avoid the
  34. segment load. In general, it's not a good idea to depend on
  35. dereferences like this as arguments to function calls.
  36.  
  37. R.
  38.  
  39.  
  40.  
  41. -- 
  42. -----------------------------------------------------------------------
  43. Rich Siegel                              Internet: siegel@world.std.com
  44. Software Engineer & Toolsmith
  45. GCC Technologies
  46.