Exemplo n.º 1
0
Arquivo: main.c Projeto: JackIrish/ios
int main(int argc, const char * argv[])
{
    SetHomeDirectory();     // set working dir to ~
    chdir( "./Desktop" );   // set working dir to ~/Desktop

	int		number;
	char	dinoName[ kDinoRecordSize+1 ];
	
    // GetNumber() returns a number typed by the user that indicates the
    //  "command" to be performed.
    //  1..n: print and optionally update a record
    //    -1: append a new record
    //     0: quit
	while ( (number = GetNumber()) != 0 ) {
        if ( number>0 ) {
            // Read the nth record and print the name
            ReadDinoName( number, dinoName );
            printf( "Dino #%d: %s\n", number, dinoName );
        } else {
            // number == -1: set number to next record #
            number = GetNumberOfDinos() + 1;
        }
		
		if ( GetNewDinoName( dinoName ) )
			WriteDinoName( number, dinoName );
	}
	
	printf( "Goodbye..." );
	
	return 0;
}
Exemplo n.º 2
0
int main (int argc, const char * argv[])
{
    int number;
    char dinoName[kDinoRecordSize + 1];
    
    while ((number = GetNumber()) != 0) {
        ReadDinoName(number, dinoName);
        printf("Dino #%d: %s\n", number, dinoName);
        if (GetNewDinoName(dinoName)) {
            WriteDinoName(number, dinoName);
        }
    }
    
    printf("Goodbye.");
    
    return 0;
}