Thread: I need to see a function return address.

  1. #46
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794

    Thumbs up

    Code:
    if ((strncmp("Seat ",var1,5))==0) {
    						sscanf(var1,"Seat %d: %s %[^\n]\n",&seatnum,player,var1);
    						if(var1[0]!='\(') {
    							sscanf(var1,"%s",var2);
    							if(strcmp(var2,"sits")){
    								sprintf(player,"%s %s",player,var2);
    							}
    						}
    						addlist(); 	seatfound=TRUE;	onefound=TRUE;
    Incidentally the above is from and older program form a different site which worked. Not sure why it suddenly started causing a problem.

    Perhaps one of the reasons I would not find it as I as convinced the code worked, which it used to!!


    Well done for spotting it!!

  2. #47
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    So I lose $0.67 per 100 games that's 15 big binds per 100 games which is pretty bad!!

    However if the average pot is 50c then in 100 games it is $50, each games has 5% rake taken off so that's £2.5 divided between the players.
    There can be from 2 to 10 players so my fair share is between $1.75 to $0.25 depending on the number.

    Seems rigged lately I was all in for $25, it required the next two cards to be 4 for me to lose. The first was a 4 and I knew the rest, another 4!!!

  3. #48
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    I recovered an older version of the program from the backup disk and ran it.

    here is the out put (it didn't crash)


    Code:
                                     (RealMoroni.txt
    01 JAWAMAN1989    0.0X    0.00P       4G      0C       4G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD JAWAMAN1989 Seat 
    02 vedder21 Sea   0.0X    0.00P       9G      0C       9G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD vedder21 Seat 
    03 el ser Seat    0.0X    0.00P      36G      0C       9G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD el ser Seat 
    04 george_shrub   0.0X    0.00P    1430G      0C    1336G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD george_shrub Seat 
    05 doloto_90 Se   0.0X    0.00P       5G      0C       5G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD doloto_90 Seat 
    06 dinomerlin S   0.0X    0.00P      19G      0C       9G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD dinomerlin Seat 
                                      CoastalSuffolk.txt
    01 AApoKerAA911   0.0X    0.00P      42G      0C      42G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD AApoKerAA911 Seat 
    02 rybka4 Seat    0.0X    0.00P      67G      0C      65G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD rybka4 Seat 
    03 george_shrub   0.0X    0.00P    1430G      0C    1336G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD george_shrub Seat 
    05 mrjimmy75 Se   0.0X    0.00P      14G      0C      14G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD mrjimmy75 Seat 
    06 lie2me88 Sea   0.0X    0.00P      24G      0C      24G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD lie2me88 Seat 
                                      (RealPointe-Noire.txt
    01 alanzan__ Se   0.0X    0.00P      35G      0C      32G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD alanzan__ Seat 
    02 Mischgi69 Se   0.0X    0.00P       3G      0C       3G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Mischgi69 Seat 
    03 jabberwocky3   0.0X    0.00P      35G      0C      32G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD jabberwocky31 Seat 
    04 amoreau007 S   0.0X    0.00P      58G      0C      55G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD amoreau007 Seat 
    05 Meroveus Sea   0.0X    0.00P       2G      0C       2G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Meroveus Seat 
    06 george_shrub   0.0X    0.00P    1430G      0C    1336G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD george_shrub Seat 
                                      (RealSeoul.txt
    01 grayslad Sea   0.0X    0.00P      63G      0C      63G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD grayslad Seat 
    02 Gizmo.electr   0.0X    0.00P      63G      0C      63G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Gizmo.electric Seat 
    03 george_shrub   0.0X    0.00P    1430G      0C    1336G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD george_shrub Seat 
    04 camilloskate   0.0X    0.00P      57G      0C      57G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD camilloskate Seat 
    05 Myxarus Seat   0.0X    0.00P      63G      0C      63G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Myxarus Seat 
    06 MistWar Seat   0.0X    0.00P     138G      0C     138G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD MistWar Seat 
    07 sereban_74 S   0.0X    0.00P      63G      0C      63G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD sereban_74 Seat 
    08 Kamovich Sea   0.0X    0.00P      51G      0C      51G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Kamovich Seat 
                                      (RealOrtaköy.txt
    01 ignatio777 S   0.0X    0.00P      35G      0C      35G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD ignatio777 Seat 
    02 knobelclown    0.0X    0.00P      66G      0C      66G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD knobelclown Seat 
    03 hchch Seat     0.0X    0.00P      35G      0C      35G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD hchch Seat 
    04 Draganta333    0.0X    0.00P      59G      0C      59G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Draganta333 Seat 
    05 kruteranio S   0.0X    0.00P      97G      0C      97G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD kruteranio Seat 
    06 Jr.Joe Seat    0.0X    0.00P      96G      0C      96G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Jr.Joe Seat 
    07 MistWar Seat   0.0X    0.00P     138G      0C     138G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD MistWar Seat 
    08 george_shrub   0.0X    0.00P    1430G      0C    1336G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD george_shrub Seat 
    09 tjc1628 Seat   0.0X    0.00P      41G      0C      41G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD tjc1628 Seat 
                                      (RealAtafu.txt
    01 george_shrub   0.0X    0.00P    1430G      0C    1336G      0C     0.0W   0.0X8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD george_shrub Seat 
    02 bbk55 Seat     0.0X    0.00P      49G      0C      49G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD bbk55 Seat 
    03 ladysonja90    0.0X    0.00P      49G      0C      49G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD ladysonja90 Seat 
    04 Pinny1990 Se   0.0X    0.00P      10G      0C      10G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Pinny1990 Seat 
    06 Kriisol Seat   0.0X    0.00P      40G      0C      40G      0C     0.0W   NaNX8    0%WON     0F   0%FW    0.0VIP    0%P   0%F   0%T   0%R NaN%SD Kriisol Seat 
    Rake 0.000000

  4. #49
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    I have a feeling if I undo nonpuz's change it may now run will test.

    I was wrong it crashed - will change back!!
    Last edited by esbo; 01-11-2013 at 11:16 AM.

  5. #50
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Well at long long last I think I may have cracked it!!
    As I had kind of suspected the problem seems to have been caused
    by blank lines which fscanf (which reads the file) skips over.


    This caused the program to get out of sync such that it no longer did the bit which processed the players sitting at the table and added them to the 'database'.

    So I think what happened was a new play say "play_new" would make a bet and my program would try to update his database record, unfortunately as he was not in the database that is not possible.

    However as he is not database it should not have got that for in
    the first place, so I am unsure why it crashed, but I think it is something to do with that but I can't quite figure it out.

    Still it seems to be working on my test data, but I need to do a bigger
    test as there could well be more bugs in there.

    So I change the bit that reads a line to
    Code:
    						strcpy(fbuff,"");
    						rc1 = fgets ( fbuff, 400, game_file_ptr );
    
    						if (rc1==NULL) {
    							printf("\n bad read1b4343"); //                            END OF A GAME
    							break;
    						}
    						strcpy(var1,""); // NEED TO CLEAR BUFFER
    						sscanf(fbuff,"%[^\n]\n",var1);
    from
    Code:
    						 rn=fscanf(game_file_ptr,"%[^\n]\n",var1);  
    						 if (rn==-1) {
    							// printf("\n bad read1b4343");                             END OF A GAME
    							// break;
    						 }

    I had to remember to clear the read buffer because if it found nothing in the line at all it left the old line in.

  6. #51
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Oh well it still has a problem on the big test but that should be easier to sort out now it does not crash and works on less test data.

  7. #52
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Finally seems to be getting to grips with this program after 6 days!!

    Seems the main problem is I ported the program over from a site which had one text file per game where as for the new site all the games for a table were in one file.
    Or it may have been that I did it OK first time and then introduced a bug trying to fix another bug!!! (because I am sure it worked fairly well at one point, however they may have changed the format of a game file.Some file have a <NUL> in. Which I can't display here
    but it's basically a line with a null (00 hex) followed by a newline (\n)
    which caused all sorts of problems

    Code:
    george_shrub wins $0.06 USD
    dskywalker89 has left the table.
    Game #12518520775 starts.
    
    #Game No : 12518520775 
    ***** Hand History for Game 12518520775 *****
    $4 USD NL Texas Hold'em - Wednesday, January 09, 14:23:33 EST 2013
    Table Suffolk Coastal (Real Money)
    Seat 2 is the button
    and

    Code:
    DrFlichsbart does not show cards.
    DrFlichsbart wins $0.23 USD
    AGrady has left the table.
    Game #11795667345 starts.
    
    NUL#Game No : 11795667345 
    ***** Hand History for Game 11795667345 *****
    $2 USD NL Texas Hold'em - Thursday, May 31, 14:08:09 EDT 2012
    Table Roudne (Real Money)

    Note the fifth line NUL#Game No : 11795667345
    Odd thing is some files seem to have it in and some don't and I can't quite figure out why.

    I just need to make sure it is not missing any files out now, and fix a minor bug in the stats processing.


    Finally produces something like this:

    Code:
                                      (RealOrtaköy.txt
    01 ignatio777    11.4X   -0.02P      35G      4C      35G      4C     3.0W  11.4X8    9%WON     3F   9%FW   11.4VIP    3%P   3%F   6%T   0%R NaN%SD ignatio777 
    02 knobelclown    6.1X    0.56P      66G      4C      66G      4C     7.0W   6.1X8   11%WON     7F  11%FW    6.1VIP    9%P   5%F   3%T   3%R NaN%SD knobelclown 
    03 hchch          2.9X    0.01P      35G      1C      35G      1C     2.0W   2.9X8    6%WON     2F   6%FW    2.9VIP    3%P   0%F   0%T   3%R NaN%SD hchch 
    04 Draganta333    5.1X   -0.86P      59G      3C      59G      3C     2.0W   5.1X8    3%WON     1F   2%FW    5.1VIP    2%P   3%F   2%T   0%R  25%SD Draganta333 
    05 kruteranio    13.4X   -1.13P      97G     13C      97G     13C    15.5W  13.5X8   16%WON    12F  12%FW   13.4VIP   12%P   1%F   5%T   3%R  19%SD kruteranio 
    06 Jr.Joe        19.8X    2.25P      96G     19C      96G     19C    16.0W  19.8X8   17%WON    11F  11%FW   19.8VIP    1%P  10%F   8%T   3%R  31%SD Jr.Joe 
    07 MistWar        9.4X   -3.77P     138G     13C     138G     13C    11.0W   9.4X8    8%WON    11F   8%FW    9.4VIP    5%P   5%F   2%T   4%R   0%SD MistWar 
    08 george_shrub  24.3X  -79.90P    6255G   1502C    5998G   1458C   929.6W  25.2X8   15%WON   704F  11%FW   24.1VIP    4%P  13%F   5%T   4%R  21%SD george_shrub 
    09 tjc1628       19.5X   -0.62P      41G      8C      41G      8C     2.0W  19.5X8    5%WON     1F   2%FW   19.5VIP    0%P   0%F   2%T   0%R  50%SD tjc1628
    I think there is bug in the last percentage on a line (SD showdowns won) the figure seems to be too low, but as it is the same bug for everyone it does not matter so much, I can still see who win more than average.
    I am pretty sure I win more than 21%!!! (I think those figures need to be doubled )
    Last edited by esbo; 01-16-2013 at 09:47 PM.

  8. #53
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    555
    I already explained to you earlier how to find a "blank line" earlier in this thread. But I'll try again..
    Code:
    rc1 = fgets ( fbuff, 400, game_file_ptr );
     
    if (rc1==NULL) {
        printf("\n bad read1b4343"); //                            END OF A GAME
        break;
    }
    While you definitely want to check the condition of fgets() returning NULL, that is not how you would check for a blank line in a file. You would check for a blank line by comparing the line to a newline by itself. Like so:
    Code:
    /* clean line with just \n */
    if (strcmp(s, "\n") == 0)
      printf("blank line\n");
    
    /* OR */
    
    /* ignore whitespace lines as well */
    if (strcspn(s, " \t\n") == 0)
      printf("blank line\n");
    The strcspn is more flexible as you can add additional "reject" characters for things you want to ignore.

  9. #54
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Quote Originally Posted by nonpuz View Post
    I already explained to you earlier how to find a "blank line" earlier in this thread. But I'll try again..
    Code:
    rc1 = fgets ( fbuff, 400, game_file_ptr );
     
    if (rc1==NULL) {
        printf("\n bad read1b4343"); //                            END OF A GAME
        break;
    }
    While you definitely want to check the condition of fgets() returning NULL, that is not how you would check for a blank line in a file. You would check for a blank line by comparing the line to a newline by itself. Like so:
    Code:
    /* clean line with just \n */
    if (strcmp(s, "\n") == 0)
      printf("blank line\n");
    
    /* OR */
    
    /* ignore whitespace lines as well */
    if (strcspn(s, " \t\n") == 0)
      printf("blank line\n");
    The strcspn is more flexible as you can add additional "reject" characters for things you want to ignore.

    Thanks but I was using fscanf at the time and this seemed to fix it.
    I just read in the 00.


    Code:
    							if ( strncmp(tmx,"#Game ",6) !=0) { 
    if (rn==0) {rn=fscanf(game_file_ptr,"%d",duffint); printf("\n duff!!");      }
    								printf("\n continue t4r5 "); continue;}
    Not 100% sure everything is working correctly not had time to check it works for all files.

    I might try your solution as well, if I get time.
    Some file have the 00 in some don't.

    Not sure if my method should have worded looking back at it but it processed to the end anyway.
    As I said I need to check for missed files, which is bit of a chore.
    Last edited by esbo; 01-17-2013 at 12:57 AM.

  10. #55
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    Quote Originally Posted by nonpuz View Post
    While you definitely want to check the condition of fgets() returning NULL, that is not how you would check for a blank line in a file. You would check for a blank line by comparing the line to a newline by itself. Like so:
    Code:
    /* clean line with just \n */
    if (strcmp(s, "\n") == 0)
      printf("blank line\n");
    
    /* OR */
    
    /* ignore whitespace lines as well */
    if (strcspn(s, " \t\n") == 0)
      printf("blank line\n");
    The strcspn is more flexible as you can add additional "reject" characters for things you want to ignore.
    How does the second example work? For example, if the input is (pretend . is a blank character like ' ' or '\t')

    ...this is not a blank line

    then strcspn will return 0, even though that is not a blank line.

    How about the following for a blank line test?

    Code:
    char end;
     	if (sscanf(s, " %c", &end) != 1)
    			printf("blank line\n");

  11. #56
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    What seemed to happen was it would not move the file pointer past the 0 however it would read past it up the the \n and copy that into
    my string buffer but the file pointer would remain pointing to the 0 and fscanf would return 0 items read successfully.
    So from the string returned it looked like it worked but it remained on that string until I read the 0 with a %d ( or %c).

    That was actually useful for synchronising the file. Fscanf is great until it comes to blank line so I have ended
    up using a fgets as well but not here, I figured I could read in that 0 and it seemed to work OK.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. function calls and return address
    By acpower in forum C Programming
    Replies: 2
    Last Post: 06-05-2012, 05:58 AM
  2. Returning Address with Return Statement?
    By Waleed Mujeeb in forum C++ Programming
    Replies: 5
    Last Post: 03-23-2012, 05:47 AM
  3. how to return address of a pointer?
    By spotty in forum C Programming
    Replies: 1
    Last Post: 02-11-2010, 08:11 PM
  4. modifying a return address of a function
    By jay1313 in forum C Programming
    Replies: 3
    Last Post: 09-18-2008, 09:09 AM
  5. Replies: 2
    Last Post: 12-07-2004, 02:31 AM