home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / c / 12312 < prev    next >
Encoding:
Text File  |  1992-08-13  |  1.6 KB  |  55 lines

  1. Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!hp9000.csc.cuhk.hk!cucs5.cs.cuhk.hk!cucs17.cs.cuhk.hk!lou1347
  2. From: lou1347@cucs17.cs.cuhk.hk
  3. Newsgroups: comp.lang.c
  4. Subject: Problem on getting video ram data
  5. Message-ID: <1992Aug12.170428.1@cucs17.cs.cuhk.hk>
  6. Date: 12 Aug 92 09:04:28 GMT
  7. Sender: news@cucs5.cs.cuhk.hk
  8. Organization: Dept of Computer Sci, CUHK
  9. Lines: 44
  10.  
  11. In last message says that:
  12.  
  13. > Leo> I wanna write a program which load the data in video ram
  14. > directly in PC.
  15. > Leo> void release(void)
  16. > Leo> {
  17. > Leo>   unsigned int count=0,vcount,code,inused;
  18. > Leo>   unsigned char far *video;
  19. > Leo>   while(count<usedno)
  20. > Leo>   {
  21. > Leo>     inused=0; video=(char far *)0xb8000000;
  22. > Leo>     for(vcount=0;vcount<2000;vcount++)
  23. > Leo>     {
  24. > Leo>       code=(*video++)+(*video++ & 8)?256:0;
  25. > According to "The C Pocket Reference" by Herbert Schildt,
  26. > Osborne McGraw-Hill, ?: operator's presedence is lower than
  27. > +'s, so code is either 256 or 0.
  28.  
  29. Thanks, but I still in trouble.  I wrote another test program like that:
  30.  
  31. #include <stdio.h>
  32. main()
  33. {
  34. char a[]={10,20},*video;
  35. int code;
  36. video=a;
  37. code=(*video++)+((*video++ & 8)?256:0);
  38. printf("%d\n",code);
  39. }
  40.  
  41. The bracket is added.  I expect the result to be 10.  But It give 276!!
  42. (If I split it into two lines, the result will be 10).
  43.  
  44. I think the problem is that the operand after '+' do first so that the 
  45. first *video got 20 and second *video got 10 which give the result 276.
  46.  
  47. But I know that in C,'+' sign will do from left to right.  ( I also write a
  48. program to test it and it is true )  So what is the result?
  49.  
  50. I am using turbo C 2.0.
  51.  
  52. Regards
  53.