Help it won't compile!!!!!

This is a discussion on Help it won't compile!!!!! within the C Programming forums, part of the General Programming Boards category; Originally Posted by esbo The compiler don't care, the processor don't care, why should I care? Heh - I guess ...

  1. #31
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by esbo View Post
    The compiler don't care, the processor don't care, why should I care?
    Heh - I guess my compiler is too young to care...

    I don't even need to turn on the -std=c99 flag; the compiler won't compile it in default mode.

  2. #32
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,269
    Quote Originally Posted by esbo
    The compiler don't care, the processor don't care, why should I care?
    Because the feature you are using is obsolescent. According to the 1999 edition of the C Standard, obsolescent features "may be considered for withdrawal in future revisions of this International Standard. They are retained because of their widespread use, but their use in new implementations (for implementation features) or new programs (for language or library features) is discouraged."

    Quote Originally Posted by tabstop
    I would guess he's using a prehistoric version of C that isn't even C89 standard.
    It is part of C99, so I believe it is part of C89 as well.

    Quote Originally Posted by kermit
    Heh - I guess my compiler is too young to care...

    I don't even need to turn on the -std=c99 flag; the compiler won't compile it in default mode.
    What compiler is that?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #33
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Finalish version, tidied up and rearranged a bit.


    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <io.h>
    #include <fcntl.h>
    #include <errno.h>
    FILE *ptr1, *ptr2, *ptr3;
    
    int filelist;
    
    int crds[3][13][13];
    int tots[3];
    char face[13]={'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
    char typ[3]={'F','M','P'};
    int gg, xx, yy, c1, c2, g1;
    char var2[300]="";
    int tmp=0;
    float freq;
    
    //M 6QUN N        
    
    main(argc,argv)
    	int  argc;
    	char *argv[]; 
    {
     
    	if (	(ptr2=fopen("hands2.doc","r")) == NULL) {
    			
    		puts("file2 does not exist");
    		exit(2);	/* an early file does not exist	*/
    	}
    	
    	
    	if (	(ptr3=fopen("handoutput.txt","w")) == NULL) {
    			
    		puts("\nCant open output file");
    		exit(2);	/* an early file does not exist	*/
    	}
    
    	do{  /* for each line in dirfile file */
    		filelist=fscanf(ptr2,"%[^\n]\n",var2);  
    		if (filelist==-1) break;
    	//	printf("\n hello var2<%s>",var2);
    
    
    //M 6QUN N        
    		xx=(char)var2[2];
    		yy=(char)var2[3];
    		gg=(char)var2[0];
    //		printf("\n %c %c%c",gg, xx,yy);
    
    		switch(xx){
    			case 'A': c1=12; break;
    			case 'K': c1=11; break;
    			case 'Q': c1=10; break;
    			case 'J': c1=9; break;
    			case 'T': c1=8; break;
    			case '9': c1=7; break;
    			case '8': c1=6; break;
    			case '7': c1=5; break;
    			case '6': c1=4; break;
    			case '5': c1=3; break;
    			case '4': c1=2; break;
    			case '3': c1=1; break;
    			case '2': c1=0; break;
    			default: printf("\n Invalid card 1");
    		}
    
    
    		switch(yy){
    
    			case 'A': c2=12; break;
    			case 'K': c2=11; break;
    			case 'Q': c2=10; break;
    			case 'J': c2=9; break;
    			case 'T': c2=8; break;
    			case '9': c2=7; break;
    			case '8': c2=6; break;
    			case '7': c2=5; break;
    			case '6': c2=4; break;
    			case '5': c2=3; break;
    			case '4': c2=2; break;
    			case '3': c2=1; break;
    			case '2': c2=0; break;
    			default: printf("\n Invalid card 2");
    		}
    		switch(gg){
    			case 'P': g1=2; break;
    			case 'T': g1=2; break;
    			case '1': g1=0; break;
    			case '2': g1=0; break;
    			case '5': g1=0; break;
    			case 'C': g1=1; break;
    			case 'M': g1=1; break;
    			default: printf("\n Invalid game type");
    		}
    
    		(crds[g1][c1][c2])++;
    		(tots[g1])++;
    	} while(1);
    
    
    	
    		for(c1=0;c1<13;c1++){
    			for(c2=c1;c2<13;c2++){
    			if (c1!=c2)	{
    					for(g1=0;g1<3;g1++){
    						freq=(float)tots[g1]/(crds[g1][c1][c2] + crds[g1][c2][c1] );
    						printf("%c Cards %c%c Count %03d   Freq %03.0f  Perc %3.2f      ", typ[g1], face[c1],face[c2], crds[g1][c1][c2], freq, 82.875/freq   );
    					}
    					printf("\n");
    				}
    
    			if (c1==c2) {
    					for(g1=0;g1<3;g1++){
    
    						freq=tots[g1]/(float)crds[g1][c1][c2];
    						printf("%c Cards %c%c Count %03d   Freq %03.0f  Perc %3.2f      ", typ[g1], face[c1],face[c2], crds[g1][c1][c2], freq, 221/freq );
    					}
    					printf("\n");
    				}
    			}
    
    		
    
    	}
    	fclose(ptr2);
    	fclose(ptr3);
    
    }
    Results:-

    Code:
    F Cards 22 Count 105   Freq 205  Perc 1.08      M Cards 22 Count 114   Freq 166  Perc 1.33      P Cards 22 Count 212   Freq 221  Perc 1.00      
    F Cards 23 Count 116   Freq 087  Perc 0.95      M Cards 23 Count 119   Freq 076  Perc 1.09      P Cards 23 Count 314   Freq 083  Perc 1.00      
    F Cards 24 Count 124   Freq 083  Perc 0.99      M Cards 24 Count 107   Freq 090  Perc 0.92      P Cards 24 Count 267   Freq 087  Perc 0.96      
    F Cards 25 Count 129   Freq 079  Perc 1.05      M Cards 25 Count 090   Freq 090  Perc 0.93      P Cards 25 Count 262   Freq 090  Perc 0.93      
    F Cards 26 Count 123   Freq 088  Perc 0.94      M Cards 26 Count 126   Freq 080  Perc 1.03      P Cards 26 Count 308   Freq 081  Perc 1.02      
    F Cards 27 Count 143   Freq 077  Perc 1.08      M Cards 27 Count 120   Freq 080  Perc 1.03      P Cards 27 Count 262   Freq 087  Perc 0.95      
    F Cards 28 Count 132   Freq 079  Perc 1.04      M Cards 28 Count 101   Freq 081  Perc 1.03      P Cards 28 Count 297   Freq 080  Perc 1.04      
    F Cards 29 Count 130   Freq 078  Perc 1.06      M Cards 29 Count 102   Freq 093  Perc 0.89      P Cards 29 Count 285   Freq 083  Perc 1.00      
    F Cards 2T Count 123   Freq 088  Perc 0.94      M Cards 2T Count 093   Freq 089  Perc 0.93      P Cards 2T Count 287   Freq 085  Perc 0.98      
    F Cards 2J Count 142   Freq 081  Perc 1.02      M Cards 2J Count 112   Freq 082  Perc 1.01      P Cards 2J Count 264   Freq 088  Perc 0.94      
    F Cards 2Q Count 135   Freq 079  Perc 1.05      M Cards 2Q Count 118   Freq 082  Perc 1.01      P Cards 2Q Count 276   Freq 079  Perc 1.05      
    F Cards 2K Count 139   Freq 080  Perc 1.03      M Cards 2K Count 116   Freq 081  Perc 1.03      P Cards 2K Count 295   Freq 081  Perc 1.02      
    F Cards 2A Count 119   Freq 086  Perc 0.97      M Cards 2A Count 134   Freq 077  Perc 1.08      P Cards 2A Count 292   Freq 082  Perc 1.01      
    F Cards 33 Count 093   Freq 232  Perc 0.95      M Cards 33 Count 080   Freq 236  Perc 0.94      P Cards 33 Count 206   Freq 227  Perc 0.97      
    F Cards 34 Count 140   Freq 079  Perc 1.05      M Cards 34 Count 108   Freq 090  Perc 0.92      P Cards 34 Count 294   Freq 080  Perc 1.04      
    F Cards 35 Count 129   Freq 082  Perc 1.01      M Cards 35 Count 107   Freq 083  Perc 1.00      P Cards 35 Count 259   Freq 091  Perc 0.91      
    F Cards 36 Count 118   Freq 085  Perc 0.98      M Cards 36 Count 119   Freq 078  Perc 1.06      P Cards 36 Count 260   Freq 083  Perc 1.00      
    F Cards 37 Count 136   Freq 084  Perc 0.99      M Cards 37 Count 126   Freq 074  Perc 1.11      P Cards 37 Count 273   Freq 079  Perc 1.05      
    F Cards 38 Count 135   Freq 085  Perc 0.97      M Cards 38 Count 097   Freq 092  Perc 0.90      P Cards 38 Count 267   Freq 089  Perc 0.93      
    F Cards 39 Count 145   Freq 080  Perc 1.04      M Cards 39 Count 100   Freq 084  Perc 0.98      P Cards 39 Count 286   Freq 080  Perc 1.04      
    F Cards 3T Count 118   Freq 095  Perc 0.87      M Cards 3T Count 101   Freq 086  Perc 0.96      P Cards 3T Count 297   Freq 081  Perc 1.03      
    F Cards 3J Count 145   Freq 075  Perc 1.10      M Cards 3J Count 106   Freq 085  Perc 0.97      P Cards 3J Count 287   Freq 083  Perc 1.00      
    F Cards 3Q Count 129   Freq 090  Perc 0.92      M Cards 3Q Count 113   Freq 088  Perc 0.95      P Cards 3Q Count 265   Freq 084  Perc 0.99      
    F Cards 3K Count 139   Freq 085  Perc 0.98      M Cards 3K Count 106   Freq 090  Perc 0.93      P Cards 3K Count 272   Freq 084  Perc 0.98      
    F Cards 3A Count 135   Freq 091  Perc 0.91      M Cards 3A Count 105   Freq 083  Perc 1.00      P Cards 3A Count 275   Freq 082  Perc 1.01      
    F Cards 44 Count 090   Freq 239  Perc 0.92      M Cards 44 Count 086   Freq 220  Perc 1.01      P Cards 44 Count 236   Freq 198  Perc 1.11      
    F Cards 45 Count 145   Freq 081  Perc 1.02      M Cards 45 Count 122   Freq 085  Perc 0.97      P Cards 45 Count 273   Freq 086  Perc 0.96      
    F Cards 46 Count 138   Freq 080  Perc 1.04      M Cards 46 Count 113   Freq 080  Perc 1.03      P Cards 46 Count 271   Freq 083  Perc 0.99      
    F Cards 47 Count 146   Freq 085  Perc 0.98      M Cards 47 Count 124   Freq 078  Perc 1.07      P Cards 47 Count 289   Freq 078  Perc 1.06      
    F Cards 48 Count 130   Freq 082  Perc 1.02      M Cards 48 Count 113   Freq 083  Perc 1.00      P Cards 48 Count 267   Freq 087  Perc 0.96      
    F Cards 49 Count 123   Freq 081  Perc 1.03      M Cards 49 Count 109   Freq 090  Perc 0.93      P Cards 49 Count 277   Freq 085  Perc 0.98      
    F Cards 4T Count 133   Freq 084  Perc 0.99      M Cards 4T Count 103   Freq 088  Perc 0.94      P Cards 4T Count 269   Freq 081  Perc 1.02      
    F Cards 4J Count 130   Freq 091  Perc 0.91      M Cards 4J Count 116   Freq 080  Perc 1.03      P Cards 4J Count 272   Freq 088  Perc 0.95      
    F Cards 4Q Count 136   Freq 086  Perc 0.96      M Cards 4Q Count 116   Freq 090  Perc 0.93      P Cards 4Q Count 262   Freq 085  Perc 0.98      
    F Cards 4K Count 137   Freq 082  Perc 1.01      M Cards 4K Count 107   Freq 088  Perc 0.94      P Cards 4K Count 274   Freq 083  Perc 0.99      
    F Cards 4A Count 120   Freq 082  Perc 1.02      M Cards 4A Count 150   Freq 069  Perc 1.20      P Cards 4A Count 269   Freq 084  Perc 0.98      
    F Cards 55 Count 076   Freq 283  Perc 0.78      M Cards 55 Count 080   Freq 236  Perc 0.94      P Cards 55 Count 204   Freq 230  Perc 0.96      
    F Cards 56 Count 138   Freq 081  Perc 1.02      M Cards 56 Count 115   Freq 081  Perc 1.02      P Cards 56 Count 313   Freq 079  Perc 1.05      
    F Cards 57 Count 149   Freq 077  Perc 1.07      M Cards 57 Count 120   Freq 084  Perc 0.99      P Cards 57 Count 295   Freq 079  Perc 1.05      
    F Cards 58 Count 149   Freq 073  Perc 1.14      M Cards 58 Count 095   Freq 092  Perc 0.90      P Cards 58 Count 284   Freq 085  Perc 0.98      
    F Cards 59 Count 139   Freq 083  Perc 1.00      M Cards 59 Count 108   Freq 087  Perc 0.95      P Cards 59 Count 256   Freq 084  Perc 0.98      
    F Cards 5T Count 129   Freq 085  Perc 0.97      M Cards 5T Count 115   Freq 086  Perc 0.97      P Cards 5T Count 290   Freq 078  Perc 1.06      
    F Cards 5J Count 125   Freq 089  Perc 0.94      M Cards 5J Count 115   Freq 074  Perc 1.12      P Cards 5J Count 273   Freq 085  Perc 0.98      
    F Cards 5Q Count 147   Freq 077  Perc 1.07      M Cards 5Q Count 115   Freq 080  Perc 1.03      P Cards 5Q Count 302   Freq 078  Perc 1.06      
    F Cards 5K Count 146   Freq 075  Perc 1.11      M Cards 5K Count 117   Freq 082  Perc 1.01      P Cards 5K Count 291   Freq 080  Perc 1.03      
    F Cards 5A Count 123   Freq 088  Perc 0.95      M Cards 5A Count 114   Freq 083  Perc 1.00      P Cards 5A Count 294   Freq 080  Perc 1.04      
    F Cards 66 Count 096   Freq 224  Perc 0.99      M Cards 66 Count 085   Freq 222  Perc 0.99      P Cards 66 Count 225   Freq 208  Perc 1.06      
    F Cards 67 Count 125   Freq 084  Perc 0.98      M Cards 67 Count 121   Freq 081  Perc 1.03      P Cards 67 Count 300   Freq 081  Perc 1.03      
    F Cards 68 Count 131   Freq 079  Perc 1.05      M Cards 68 Count 108   Freq 087  Perc 0.96      P Cards 68 Count 274   Freq 086  Perc 0.96      
    F Cards 69 Count 111   Freq 089  Perc 0.93      M Cards 69 Count 116   Freq 083  Perc 1.00      P Cards 69 Count 284   Freq 081  Perc 1.03      
    F Cards 6T Count 125   Freq 084  Perc 0.99      M Cards 6T Count 099   Freq 084  Perc 0.99      P Cards 6T Count 296   Freq 080  Perc 1.03      
    F Cards 6J Count 136   Freq 079  Perc 1.05      M Cards 6J Count 114   Freq 084  Perc 0.99      P Cards 6J Count 273   Freq 082  Perc 1.01      
    F Cards 6Q Count 129   Freq 077  Perc 1.08      M Cards 6Q Count 104   Freq 095  Perc 0.88      P Cards 6Q Count 287   Freq 086  Perc 0.97      
    F Cards 6K Count 137   Freq 085  Perc 0.97      M Cards 6K Count 107   Freq 089  Perc 0.93      P Cards 6K Count 266   Freq 083  Perc 0.99      
    F Cards 6A Count 133   Freq 084  Perc 0.99      M Cards 6A Count 130   Freq 079  Perc 1.05      P Cards 6A Count 268   Freq 081  Perc 1.02      
    F Cards 77 Count 084   Freq 256  Perc 0.86      M Cards 77 Count 081   Freq 233  Perc 0.95      P Cards 77 Count 231   Freq 203  Perc 1.09      
    F Cards 78 Count 117   Freq 091  Perc 0.91      M Cards 78 Count 125   Freq 079  Perc 1.05      P Cards 78 Count 238   Freq 092  Perc 0.90      
    F Cards 79 Count 129   Freq 081  Perc 1.02      M Cards 79 Count 107   Freq 085  Perc 0.98      P Cards 79 Count 273   Freq 081  Perc 1.02      
    F Cards 7T Count 122   Freq 084  Perc 0.98      M Cards 7T Count 108   Freq 087  Perc 0.96      P Cards 7T Count 285   Freq 081  Perc 1.03      
    F Cards 7J Count 150   Freq 075  Perc 1.10      M Cards 7J Count 142   Freq 072  Perc 1.15      P Cards 7J Count 315   Freq 077  Perc 1.08      
    F Cards 7Q Count 126   Freq 082  Perc 1.02      M Cards 7Q Count 113   Freq 081  Perc 1.02      P Cards 7Q Count 278   Freq 081  Perc 1.02      
    F Cards 7K Count 132   Freq 079  Perc 1.04      M Cards 7K Count 117   Freq 084  Perc 0.99      P Cards 7K Count 283   Freq 085  Perc 0.98      
    F Cards 7A Count 131   Freq 085  Perc 0.98      M Cards 7A Count 106   Freq 087  Perc 0.95      P Cards 7A Count 286   Freq 086  Perc 0.97      
    F Cards 88 Count 090   Freq 239  Perc 0.92      M Cards 88 Count 089   Freq 212  Perc 1.04      P Cards 88 Count 194   Freq 241  Perc 0.92      
    F Cards 89 Count 135   Freq 084  Perc 0.98      M Cards 89 Count 113   Freq 083  Perc 1.00      P Cards 89 Count 280   Freq 081  Perc 1.02      
    F Cards 8T Count 122   Freq 081  Perc 1.02      M Cards 8T Count 111   Freq 084  Perc 0.99      P Cards 8T Count 254   Freq 082  Perc 1.01      
    F Cards 8J Count 128   Freq 084  Perc 0.98      M Cards 8J Count 115   Freq 083  Perc 1.00      P Cards 8J Count 294   Freq 080  Perc 1.04      
    F Cards 8Q Count 143   Freq 083  Perc 1.00      M Cards 8Q Count 113   Freq 086  Perc 0.97      P Cards 8Q Count 294   Freq 084  Perc 0.98      
    F Cards 8K Count 119   Freq 082  Perc 1.02      M Cards 8K Count 129   Freq 076  Perc 1.09      P Cards 8K Count 281   Freq 083  Perc 1.00      
    F Cards 8A Count 133   Freq 080  Perc 1.04      M Cards 8A Count 086   Freq 093  Perc 0.89      P Cards 8A Count 288   Freq 082  Perc 1.01      
    F Cards 99 Count 093   Freq 232  Perc 0.95      M Cards 99 Count 090   Freq 210  Perc 1.05      P Cards 99 Count 201   Freq 233  Perc 0.95      
    F Cards 9T Count 125   Freq 087  Perc 0.95      M Cards 9T Count 127   Freq 078  Perc 1.06      P Cards 9T Count 282   Freq 085  Perc 0.98      
    F Cards 9J Count 132   Freq 078  Perc 1.06      M Cards 9J Count 116   Freq 081  Perc 1.03      P Cards 9J Count 322   Freq 080  Perc 1.04      
    F Cards 9Q Count 114   Freq 090  Perc 0.92      M Cards 9Q Count 103   Freq 083  Perc 1.00      P Cards 9Q Count 269   Freq 084  Perc 0.98      
    F Cards 9K Count 121   Freq 084  Perc 0.98      M Cards 9K Count 121   Freq 078  Perc 1.07      P Cards 9K Count 260   Freq 086  Perc 0.96      
    F Cards 9A Count 138   Freq 081  Perc 1.02      M Cards 9A Count 098   Freq 088  Perc 0.94      P Cards 9A Count 285   Freq 080  Perc 1.04      
    F Cards TT Count 105   Freq 205  Perc 1.08      M Cards TT Count 080   Freq 236  Perc 0.94      P Cards TT Count 230   Freq 204  Perc 1.09      
    F Cards TJ Count 138   Freq 081  Perc 1.02      M Cards TJ Count 109   Freq 096  Perc 0.86      P Cards TJ Count 259   Freq 084  Perc 0.99      
    F Cards TQ Count 111   Freq 093  Perc 0.89      M Cards TQ Count 109   Freq 087  Perc 0.96      P Cards TQ Count 283   Freq 081  Perc 1.02      
    F Cards TK Count 131   Freq 088  Perc 0.94      M Cards TK Count 117   Freq 082  Perc 1.01      P Cards TK Count 250   Freq 090  Perc 0.92      
    F Cards TA Count 119   Freq 082  Perc 1.01      M Cards TA Count 115   Freq 077  Perc 1.07      P Cards TA Count 284   Freq 084  Perc 0.99      
    F Cards JJ Count 091   Freq 237  Perc 0.93      M Cards JJ Count 093   Freq 203  Perc 1.09      P Cards JJ Count 206   Freq 227  Perc 0.97      
    F Cards JQ Count 133   Freq 080  Perc 1.04      M Cards JQ Count 108   Freq 083  Perc 1.00      P Cards JQ Count 266   Freq 086  Perc 0.96      
    F Cards JK Count 119   Freq 093  Perc 0.89      M Cards JK Count 127   Freq 074  Perc 1.12      P Cards JK Count 268   Freq 085  Perc 0.97      
    F Cards JA Count 137   Freq 083  Perc 0.99      M Cards JA Count 127   Freq 079  Perc 1.05      P Cards JA Count 291   Freq 084  Perc 0.98      
    F Cards QQ Count 099   Freq 217  Perc 1.02      M Cards QQ Count 081   Freq 233  Perc 0.95      P Cards QQ Count 198   Freq 236  Perc 0.93      
    F Cards QK Count 125   Freq 074  Perc 1.12      M Cards QK Count 118   Freq 082  Perc 1.01      P Cards QK Count 290   Freq 082  Perc 1.01      
    F Cards QA Count 131   Freq 083  Perc 0.99      M Cards QA Count 126   Freq 078  Perc 1.07      P Cards QA Count 303   Freq 081  Perc 1.02      
    F Cards KK Count 097   Freq 222  Perc 1.00      M Cards KK Count 072   Freq 263  Perc 0.84      P Cards KK Count 205   Freq 228  Perc 0.97      
    F Cards KA Count 135   Freq 082  Perc 1.02      M Cards KA Count 114   Freq 080  Perc 1.04      P Cards KA Count 284   Freq 081  Perc 1.02      
    F Cards AA Count 106   Freq 203  Perc 1.09      M Cards AA Count 104   Freq 182  Perc 1.22      P Cards AA Count 226   Freq 207  Perc 1.07      
    
    Would be better if I just printed the cards and the 'percentage frequence' above or below the normal value of 1, perhaps.
    Note I have added for example AQ to QA as the order does not matter.
    Probably would have been better if I started from Ace instead of two.

  4. #34
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    Quote Originally Posted by laserlight View Post
    Because the feature you are using is obsolescent. According to the 1999 edition of the C Standard, obsolescent features "may be considered for withdrawal in future revisions of this International Standard. They are retained because of their widespread use, but their use in new implementations (for implementation features) or new programs (for language or library features) is discouraged."
    Is this the same definition of obsolescent that perpetuates the implementation of gets in the stdio library? Discussions aside, that sort of consideration is a false promise at best. gets was obsolescent from inception. Even if we didn't know it at the time.

  5. #35
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,528
    Quote Originally Posted by laserlight View Post
    What compiler is that?
    gcc version 4.1.2

  6. #36
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,269
    Quote Originally Posted by esbo
    Finalish version, tidied up and rearranged a bit.
    Have you considered renaming crds to cards, tots to totals, typ to type, and then using more descriptive names than ptr1 and gg? After all, as you know from your use of the name filelist, variable names are not limited to 4 characters, so you might as well be descriptive about them, especially since you simply refuse to avoid global variables.

    Quote Originally Posted by whiteflags
    Is this the same definition of obsolescent that perpetuates the implementation of gets in the stdio library
    No, gets is not obsolescent, as far as I can tell. It is "merely" bad practice.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #37
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    I may develop it to see if I get the expected numbers of pair, sets, straights and flushs etc..
    It seems like I am not getting my 'fair share'

  8. #38
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,762
    Quote Originally Posted by laserlight View Post
    Have you considered renaming crds to cards, tots to totals, typ to type, and then using more descriptive names than ptr1 and gg? After all, as you know from your use of the name filelist, variable names are not limited to 4 characters, so you might as well be descriptive about them, especially since you simply refuse to avoid global variables.


    No, gets is not obsolescent, as far as I can tell. It is "merely" bad practice.
    Concerning the first, esbo seems to think that descriptive names are only worth it when they solve some other problem, except now he can't be arsed. No way to make head way at all. Luckily, he only writes things that he never needs to maintain, or if he does, he always remembers what some obscure identifier meant. I assume he can't be arsed to write comments either, because that's a waste of space, but he's a lucky guy. I wonder how he keeps his memory recall so spot on.

    Concerning the second, well that's a shame.

  9. #39
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Quote Originally Posted by laserlight View Post
    Have you considered renaming crds to cards, tots to totals, typ to type, and then using more descriptive names than ptr1 and gg? After all, as you know from your use of the name filelist, variable names are not limited to 4 characters, so you might as well be descriptive about them, especially since you simply refuse to avoid global variables.


    No, gets is not obsolescent, as far as I can tell. It is "merely" bad practice.

    Well I did consider the idea, however the problem with long variable names is that they are well, long. So you end up with messy long lines. However I did leave them sufficiently unigue so that I could change them with a global edit.
    Filelist is the only variable I can't remember what I used it for - lol.
    Should have called it FileReadReturnRalue, but imagine haveing to type they in all the time

    I find the difficulty with long names and hence long code is it just makes the program harder to understand as there is less code on the screen.

  10. #40
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,269
    Quote Originally Posted by esbo
    Well I did consider the idea, however the problem with long variable names is that they are well, long. So you end up with messy long lines.
    You can always extend a line to the next since C is free form, and besides, excessively long lines are an indication that some of the code should be abstracted away into another function.

    Quote Originally Posted by esbo
    Filelist is the only variable I can't remember what I used it for - lol.
    Should have called it FileReadReturnRalue, but imagine haveing to type they in all the time
    I can agree that FileReadReturnRalue is bordering on an excessively long name (but not yet too long, in my opinion), but it so happens that you do not even need that variable at all. Instead of writing:
    Code:
    filelist=fscanf(ptr2,"%[^\n]\n",var2);
    if (filelist==-1) break;
    you could have written:
    Code:
    if (fscanf(ptr2,"%[^\n]\n",var2) == -1) break;
    This is an advantage of declaring variables near first use: it is easier to see what variables you actually need at that point.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #41
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Quote Originally Posted by whiteflags View Post
    Concerning the first, esbo seems to think that descriptive names are only worth it when they solve some other problem, except now he can't be arsed. No way to make head way at all. Luckily, he only writes things that he never needs to maintain, or if he does, he always remembers what some obscure identifier meant. I assume he can't be arsed to write comments either, because that's a waste of space, but he's a lucky guy. I wonder how he keeps his memory recall so spot on.

    Concerning the second, well that's a shame.
    Well as I said they create another problem in that they make the program longer and wider which in itself makes it harder to read.
    I do write stuff which I need to maintain, but it is not much of a problem figuring out what a variable is, a quick search through the code on the variable tells me that.
    Also it is quite hard sometiimes to think up a useful variable name without it being an entire sentence or even essay - lol. I do have a pretty good memory I suppose, probably down to practise!! But it requires less memory to store short variable names!!
    What amazes me is how people can remember long name with 20-30 characters in some of them uppercase, it's people who can do that who have a good memory in my opinion!!
    crds is a reasonal abreviation, as is tots. c1= card 1 etc...
    gg probably was not a very god one.
    I tend to only use short obscure names if they are used very frequently or in a vary localised area. That's what we do in the English language so it is fairly natural eg:-
    a I it an on at of be to in the of etc.....

  12. #42
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I think you should consider taking that program a bit further, and having it plot a distribution curve for all your hands - individually by type (pairs, sets, etc.), and also as a whole. In the background, put up a perfect bell shaped distribution curve, and then overlay your data, with a different color or colors.

    With a little studying, you could then test your data and see if your hands really are "fair".

  13. #43
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,269
    Quote Originally Posted by esbo
    Also it is quite hard sometiimes to think up a useful variable name without it being an entire sentence or even essay - lol. I do have a pretty good memory I suppose, probably down to practise!! But it requires less memory to store short variable names!!
    What amazes me is how people can remember long name with 20-30 characters in some of them uppercase, it's people who can do that who have a good memory in my opinion!!
    crds is a reasonal abreviation, as is tots. c1= card 1 etc...
    Abbreviating ExtendedMarkupLanguageHyperTextTransferProtocolReq uest to XmlHttpRequest is certainly reasonable (and advisable), and especially so since XML and HTTP are well known abbreviations, but abbreviating cards to crds is senseless since cards is already a sufficiently short name, and the same goes for abbreviating totals to tots.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  14. #44
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Quote Originally Posted by Adak View Post
    I think you should consider taking that program a bit further, and having it plot a distribution curve for all your hands - individually by type (pairs, sets, etc.), and also as a whole. In the background, put up a perfect bell shaped distribution curve, and then overlay your data, with a different color or colors.

    With a little studying, you could then test your data and see if your hands really are "fair".
    One thing I have done before is to add up how much each hand win or loses, I have done that before but not in one neat program. It should be easy to do with this one because I nave another program which extracts the data from the history of each game.

    Code:
    1 82UB N  [3s As 6d]            -20.00   
    1 A6US N  [Js 6d Qc Kh][Ts]     155.00  
    1 62SN N  [3h 6c Ts 8s][Qc]    -120.00  
    1 JKUN N  [9s Ad Qd Qc][8h]     -90.00
    Where
    1 82UB N [3s As 6d] -20.00
    would be, game type 1, cards 8,2, U/S suited unsuited, B=big blind an indicator if I had to put money into the pot, N= an indicator of if and when I went 'all in' and then the value won or lost.

    So I can get an idea of which hands win or lose and simply not play those hands!!
    However it is a bit more complicated as the number of people at the table also matters.

    Also would be interesting to see if I win more when I raise with AA preflop, but again I vary that depending on varius factors depending on position at table and if in a tournement and at what stage and how the other players are playing eg loose/tight.
    So it can get really complicated!!

    However when you realise that in the past you have made a loss playing certain hands
    the logical thing to do is to simply not play them at all!!

    Again it depends on table size, Q8 is a half decent hand, marginaly better than average 1 on 1, but on a ten player table it is pretty rubbish.

  15. #45
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,012
    esbo, try compiling your code is a modern compiler that supports C99.
    Newer compilers usually create more optimized code, as well, and you want fast code, do you not?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 3 of 4 FirstFirst 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C and C++ compile speed
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2007, 02:37 PM
  2. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 01:36 PM
  3. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 08:20 AM
  4. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM
  5. How can I compile C or C++ with Visual Studio .NET?
    By Dakkon in forum C Programming
    Replies: 8
    Last Post: 02-11-2003, 02:58 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21