giocatore cambiaCarte (giocatore *gioc, int numGioc, carta mazzo[4][13]) {
	int numCambi, i, indiceCarta;

	stampaMano (gioc, numGioc);

	printf("\nQuante carte vuoi cambiare?\n");
	do {
		fpurge(stdin);
		printf("									» ");
	} while (scanf("%d", &numCambi) != 1 || numCambi < 0 || numCambi > 4);

	if (numCambi != 0) {
		for(i = 0; i < numCambi; i++) {
			printf("\nInserire posizione della carta da cambiare nella mano (1 - 5)\n");
			do {
				fpurge(stdin);
				printf("											» ");
			} while(scanf("%d", &indiceCarta) != 1 || indiceCarta < 1 || indiceCarta > 5);
			gioc[numGioc].mano[indiceCarta -1] = distribuisciCarta(mazzo);
		}
		stampaMano (gioc, numGioc);
	}
	stampaDivisorio();
	return gioc[numGioc];
} //cambia carte OK
int puntaVedi (giocatore *gioc, int numGioc) {
	int scelta, puntata = 0;
	ordinaMano(gioc, numGioc);
	stampaMano (gioc, numGioc);
	printf("\nIl tuo portafogli attuale è: €%d\n", gioc[numGioc].cash);
	printf("\nCosa vuoi fare?\n");
	printf("1 » Rilancia\n");
	printf("2 » Vedi\n");
	printf("3 » Lascia\n");

	do {
		fpurge(stdin);
		printf("		» ");
	}while (scanf("%d", &scelta) != 1 || (scelta < 1 || scelta > 3));

	switch (scelta) {
			//punta
		case 1:
			printf("Quanto vuoi puntare?\n");
			do {
				fpurge(stdin);
				printf("		» € ");
			}while (scanf("%d", &puntata) != 1 || puntata < 1 || puntata > gioc[numGioc].cash || puntata <= puntataPrec);
			contaVedi = 0;
			puntataPrec = puntata;
			gioc[numGioc].puntata = puntata;
			gioc[numGioc].cash -= puntata;
			if (gioc[numGioc].cash <= 0) {
				printf("Non hai più soldi, sei andato in ALL IN\n");
			} else {
				printf("Rilanci. Hai puntato €%d, ti rimangono €%d\n", puntata, gioc[numGioc].cash);
			}
			break;
			//vedi
		case 2:
			contaVedi++;
			if (puntataPrec != gioc[numGioc].puntata) {
				gioc[numGioc].cash -= puntataPrec;
			} else {
				puntataPrec = 0;
			}
			printf("Vedi. Hai puntato €%d, ti rimangono €%d\n", puntataPrec, gioc[numGioc].cash);
			if (gioc[numGioc].cash <= 0) {
				printf("Non hai più soldi, sei andato in ALL IN\n");
			}
			puntata = puntataPrec;
			break;
		case 3:
			//folda
			printf("Hai lasciato la mano.");
			gioc[numGioc].fold = TRUE;
			puntata = 0;
			contaFold++;
			break;
	}

	stampaDivisorio();
	return puntata;
}
Example #3
0
void DoNewCommand()
{
    char yesOrNo;
    //  First create a new array element (or a new array if we do not have one yet):
    if ( gDatabase == NULL )
    {
        gDatabase = malloc( sizeof(struct CDDatabaseEntry));    // Size of one element.
        if ( gDatabase == NULL) {
            printf("ERROR: could not create a new entry!\n");
            return;
        }
    }
    else
    {
        struct CDDatabaseEntry* newPtr = NULL;
        newPtr = realloc( gDatabase, (gNumDatabaseEntries + 1) * sizeof(struct CDDatabaseEntry));
        if ( newPtr == NULL)    //  Error. Out of memory?
        {
            // Wejust keep the old pointer in gDatabase
            printf("ERROR: Could not create a new entry!\n" );
            return;
        }
        // newPtr is our new ptr, gDatabase is no longer valid!
        gDatabase = newPtr;     //  Rememer newPtr in gDatabase
    }
    
    //  Make sure we remember that we have one more entry
    gNumDatabaseEntries += 1;
    
    //  Now replace the garbage data in the new, last entry with the data the user entered:
    printf("Artist Name: ");
    scanf("39%s", gDatabase[ gNumDatabaseEntries - 1].artist);
    fpurge(stdin);
    
    printf( "Composer: " );
    scanf( "%39s", gDatabase[ gNumDatabaseEntries -1 ].composer );
    fpurge( stdin );
    
    printf( "Album Name: " );
    scanf( "%39s", gDatabase[ gNumDatabaseEntries -1 ].albumName );
    fpurge( stdin );
    
    printf( "No. of Tracks: " );
    scanf( "%d", &gDatabase[ gNumDatabaseEntries -1 ].trackCount );
    fpurge( stdin );
    
    printf( "Sampler? (y/n): " );
    scanf( "%c", &yesOrNo );
    fpurge( stdin );
    
    gDatabase[ gNumDatabaseEntries - 1 ].isSampler = (yesOrNo == 'y' || yesOrNo == 'Y');
    
}
int
main ()
{
  FILE *fp;

  /* Create a file with some contents.  */
  fp = fopen (TESTFILE, "w");
  if (fp == NULL)
    goto skip;
  if (fwrite ("foobarsh", 1, 8, fp) < 8)
    goto skip;
  if (fclose (fp))
    goto skip;

  /* Open it in read-write mode.  */
  fp = fopen (TESTFILE, "r+");
  if (fp == NULL)
    goto skip;
  if (fseek (fp, 3, SEEK_CUR))
    goto skip;
  if (fwrite ("g", 1, 1, fp) < 1)
    goto skip;
  if (fflush (fp))
    goto skip;
  if (fwrite ("az", 1, 2, fp) < 2)
    goto skip;
  ASSERT (fpurge (fp) == 0);
  ASSERT (fclose (fp) == 0);

  /* Open it in read-only mode.  */
  fp = fopen (TESTFILE, "r");
  if (fp == NULL)
    goto skip;
  {
    char buf[8];
    if (fread (buf, 1, 8, fp) < 8)
      goto skip;
    ASSERT (memcmp (buf, "foogarsh", 8) == 0);
  }
  ASSERT (fpurge (fp) == 0);
  ASSERT (fclose (fp) == 0);

  return 0;

 skip:
  fprintf (stderr, "Skipping test: file operations failed.\n");
  return 77;
}
Example #5
0
int main (int argc, const char * argv[])
{
    struct CDDataEntry myEntries[10];
    bool keepRunning = true;
    char userInput[11];
    
    while(keepRunning == true){
        printf("\nType NEW, LIST, or QUIT:\n ");
        scanf("%10s",userInput);
        fpurge(stdin);
        
        if(strcmp(userInput, "NEW") == 0){
            printf("NEW");
        }else if(strcmp(userInput, "LIST") == 0){
            printf("LIST");
        }else if (strcmp(userInput, "QUIT") == 0){
            printf("QUIT");
            keepRunning = false;
        }else{
            printf("Invalid Command! \n");
        }
    }
    
    return 0;
}
Example #6
0
int getRoomChoice() {
    printf("Type a number (1-6):");
    fpurge(stdin);
    int numberScanned;
    int choiceNumber;
    numberScanned = scanf("%d", &choiceNumber);
    if (choiceNumber == 1) {
        roomOne();
    }
    if (choiceNumber == 4) {
        roomFour();
    }
    if (choiceNumber == 6) {
        roomSix();
    }
    if (choiceNumber == 5) {
        roomFive();
    }
    if (choiceNumber == 2) {
        roomTwo();
    }
    if (choiceNumber == 3) {
        roomThree();
    }
    return choiceNumber;
    }
Example #7
0
int main()
{
	int number;
	float iq;
	char first;

	puts("IQ Calculator\n");

	printf("Enter your house or apartment number:");
	scanf("%d", &number);
    fpurge(stdin);

	printf("Enter the first letter of your last name:");
	scanf("%c", &first);

	puts("\n\n\tCalculating your IQ.... \n\t\t......");

	iq = (float)number / first;

	if (iq <= 50)
		iq = iq * 2;
	if (iq > 50 && iq < 80)
		iq = iq + 50;

	printf("Your IQ is probably ... %f\r", iq);

	return (0);
}
Example #8
0
int chooseOutputType()
{
	char choice[3] = "";

	printf("Save to txt\t(1) \n");
	printf("Save as html\t(2)\n");
	printf("Quit\t\t(3) \n");

	printf("Enter: ");
	fgets(choice, 2, stdin);

	if((strlen(choice)>0) && (choice[strlen (choice) - 1] == '\n')){
		choice[strlen (choice) - 1] = '\0';
	}
	
    	fpurge(stdin);
    
	switch (choice[0]) {
	case '1':
		return 1;
	case '2':
		return 2;
	case '3':
		exit(0);
	default:
		return 99;
	}
}
Example #9
0
File: sist.c Project: wrmsr/urbit
/* _sist_text(): ask for a name string.
*/
static u3_noun
_sist_text(c3_c* pom_c)
{
  c3_c   paw_c[60];
  u3_noun say;

  uH;
  while ( 1 ) {
    printf("%s: ", pom_c);

    paw_c[0] = 0;
    fpurge(stdin);
    fgets(paw_c, 59, stdin);

    if ( '\n' == paw_c[0] ) {
      continue;
    }
    else {
      c3_w len_w = strlen(paw_c);

      if ( paw_c[len_w - 1] == '\n' ) {
        paw_c[len_w-1] = 0;
      }
      say = u3i_string(paw_c);
      break;
    }
  }
  uL(0);
  return say;
}
Example #10
0
//function that displays the menu
 void display_menu(){

 	 char menu_number;
 	
 	 printf("\nWelcome to the CD database.\n");
 	 printf("1. File: Create a new list\n");
 	 printf("2.       Open an existing list\n");
 	 printf("3.       Save the list\n");
 	 printf("4.       Save the list with a new name\n");
 	 printf("5.       Append list to another file\n");
 	 printf("6. Edit: Create a new record\n");
 	 printf("7. View: Display a specific record\n");
 	 printf("8.       Display a specific record\n");
 	 printf("9. Exit\n");

 	 fpurge(stdin);
 	 menu_number = getchar();

 	 switch (menu_number){
 	 	case '1': printf("File: Create a new list\n");
 	 	 break;
 	 	case '2': printf("Open an existing list\n");
 	 	 break;
 	 	default: printf("Error\n");
 	 	 break;   
 	 }
   
 };
Example #11
0
int
main()
{
	static FILE fp_bad;
	FILE *fp;

	if (fpurge(&fp_bad) == 0)
		return 1;

	fp = fopen("/dev/zero", "r");
	if (fpurge(fp) < 0)
		return 1;

	fclose(fp);

	return 0;
}
/**
 * \brief Solicita un caracter al usuario y devuelve el resultado
 * \param mensaje Es el mensaje a ser mostrado
 * \return El caracter ingresado por el usuario
 *
 */
char getChar(char mensaje[])
{
    char auxiliar;
    printf("%s",mensaje);
    fflush(stdin);
    fpurge(stdin);
    scanf("%c",&auxiliar);
    return auxiliar;
}
Example #13
0
void
interactive(long long *choice)
{
	fprintf(stdout, "\n");
	do {
		fpurge(stdin);
		fprintf(stdout, "Choice > ");
	} while (!scanf("%lld", choice));
}
Example #14
0
/* Flush all pending data on STREAM according to POSIX rules.  Both
   output and seekable input streams are supported.  */
int
rpl_fflush (FILE *stream)
{
  int result;
  off_t pos;

  /* When stream is NULL, POSIX and C99 only require flushing of "output
     streams and update streams in which the most recent operation was not
     input", and all implementations do this.

     When stream is "an output stream or an update stream in which the most
     recent operation was not input", POSIX and C99 requires that fflush
     writes out any buffered data, and all implementations do this.

     When stream is, however, an input stream or an update stream in
     which the most recent operation was input, C99 specifies nothing,
     and POSIX only specifies behavior if the stream is seekable.
     mingw, in particular, drops the input buffer, leaving the file
     descriptor positioned at the end of the input buffer. I.e. ftell
     (stream) is lost.  We don't want to call the implementation's
     fflush in this case.

     We test ! freading (stream) here, rather than fwriting (stream), because
     what we need to know is whether the stream holds a "read buffer", and on
     mingw this is indicated by _IOREAD, regardless of _IOWRT.  */
  if (stream == NULL || ! freading (stream))
    return fflush (stream);

  /* POSIX does not specify fflush behavior for non-seekable input
     streams.  Some implementations purge unread data, some return
     EBADF, some do nothing.  */
  pos = ftello (stream);
  if (pos == -1)
    {
      errno = EBADF;
      return EOF;
    }

  /* To get here, we must be flushing a seekable input stream, so the
     semantics of fpurge are now appropriate to clear the buffer.  To
     avoid losing data, the lseek is also necessary.  */
  result = fpurge (stream);
  if (result != 0)
    return result;

  pos = lseek (fileno (stream), pos, SEEK_SET);
  if (pos == -1)
    return EOF;
  /* After a successful lseek, update the file descriptor's position cache
     in the stream.  */
#if defined __sferror           /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
  stream->_offset = pos;
  stream->_flags |= __SOFF;
#endif

  return 0;
}
Example #15
0
int main(int argc, const char * argv[]) {
    
    struct teenager {
        char *questionTeenager;
        char *yellAtTeenager;
        char *addressTeenager;
        char *everythingElse;
    };
    
    typedef struct teenager Teenager;
    
    Teenager Adam;
    Adam.questionTeenager = "Sure";
    Adam.yellAtTeenager = "Whoa, chill out!";
    Adam.addressTeenager = "Fine. Be that way!";
    Adam.everythingElse = "Whatever";
    
    while (1) {
        char conversationInput[256];
        printf("You say: ");
        scanf("%[^\n]", conversationInput);
        fpurge(stdin);
        
        // check for lower case (if time put this in it's own function)
        int i = 0;
        int isAllUpperCase = 1;
        
        while (conversationInput[i] != '\0') {
            if (conversationInput[i] >= 'a' && conversationInput[i] <= 'z') {
                isAllUpperCase = 0;
                break;
            }
            i++;
        }
        
        // check for empty input
        if (strlen(conversationInput) == 0) {
            printf("Adam says: %s\n", Adam.addressTeenager);
        }
        else if (strchr(conversationInput, '?') != NULL) {
            printf("Adam says: %s\n", Adam.questionTeenager); // "Sure"
        }
        else if (isAllUpperCase == 1) {
            printf("Adam says: %s\n", Adam.yellAtTeenager ); // "Whoa, chill out"
        }
        else if (strcmp(conversationInput, "exit") == 0){
            break;
        }
        else {
            printf("Adam says: %s\n", Adam.everythingElse); // "Whatever"
        }
    
        
        strncpy(conversationInput, "", strlen(conversationInput)); // clear the output
    }
    return 0;
}
Example #16
0
void doNewCommand(){
    char yesOrNo;
    
    if(gDatabase == NULL){
        gDatabase = malloc(sizeof(struct CDDataEntry));
        if(gDatabase == NULL){
            printf("ERROR: couldn't create new entry!\n");
            return;
        }
    }else{
        struct CDDataEntry* newPtr = NULL;
        newPtr = realloc(gDatabase, gNumDatabaseEntries+1);
        if(newPtr == NULL){
            printf("ERROR: could not create new entry");
            return;
        }
        gDatabase = newPtr;
    }
    
    gNumDatabaseEntries += 1;
    
    printf("Artist Name: ");
    scanf("%39s", gDatabase[gNumDatabaseEntries-1].artist);
    fpurge(stdin);
    
    printf("Composer Name: ");
    scanf("%39s", gDatabase[gNumDatabaseEntries-1].composer);
    fpurge(stdin);
    
    printf("Album Name: ");
    scanf("%39s", gDatabase[gNumDatabaseEntries-1].albumName);
    fpurge(stdin);
    
    printf("No. of Tracks: ");
    scanf("%d", gDatabase[gNumDatabaseEntries-1].trackCount);
    fpurge(stdin);
    
    printf("Sampler? (y/n) ");
    scanf("%c", &yesOrNo);
    fpurge(stdin);
    
    gDatabase[gNumDatabaseEntries-1].isSampler = (yesOrNo == 'y' || yesOrNo == 'Y');
    
}
static bool didGetDialog()
{
	fpurge(stdin);
	printf("Enter 'y' if you just got a keychain unlock dialog: ");
	if(getchar() == 'y') {
		return 1;
	}
	printf("***Well, you really should have. Test failed.\n");
	return 0;
}
static int doPause(const char *state)
{
	char resp;

	fpurge(stdin);
	printf("%s\n", state);
	printf("q to abort, anything else to continue: ");
	resp = getchar();
	return(resp == 'q');
}
Example #19
0
int main()									// integer function
{
	
	int vFirstArg,							// integer variable declarations
		vSecondArg;
	char	vOperation;						// character variable declaration
	bool	vFinished;						// boolean variable declaration

	vFinished = false;    					// initialized flag. 


	while( vFinished != true )				// while "vFinished is not true" is a true statement....the command below will run until vFinished is false.
	{

		printf( "What operation do you want to do?\n" ); // write "What operation do you want to do?"
		scanf( "%c", &vOperation );						//  read input, input is a character variable called vOperation
		fpurge( stdin );								// done reading. will write again.

		if( vOperation == '+')							//  if character variable matches comparison of +....
		{

			printf("Enter left argument:\n");			//	write "Enter left argument:"
			scanf("%d", &vFirstArg);					// read input, input is an integer variable called vFirstArg
			fpurge( stdin );							// done reading. will write again.

			printf("\nEnter right argument: " );        // write "Enter right argument: "
			scanf( "%d", &vSecondArg);					// read input, input is an integer variable called vSecondArg
			fpurge( stdin );							// done reading. will write again.

			printf("\n%d + %d = %d\n",					// write "vFirstArg + vSecondArg = integer"
						vFirstArg,
						vSecondArg,
						vFirstArg + vSecondArg );
		}
		else											// if character variable called vOperation is not +, "vFinished != true" becomes a FALSE STATEMENT 
			vFinished = true;							// if vFinished is true.....
	}

	printf("Finished . \n");							// write "Finished"


	return 0;											// it's OK!
} 
void peticion_array(int array_x[], int array_y[])
{
    printf("\nIserta 10 números enteros para el array 'X':\n");
    fflush(stdout);
    fpurge(stdin);
    leer_array(array_x);
    
    printf("\nIserta 10 numeros enteros para el array 'Y':\n");
    fflush(stdout);
    fpurge(stdin);
    leer_array(array_y);
    
    printf("\n---------------------\n");
    
    printf("\nElementos del array X:\n");
    visualizar_array(array_x);
    printf("\n\nElementos del array Y:\n");
    visualizar_array(array_y);
}
/* decode --> encode */
int p12Reencode(
	const CSSM_DATA &pfx,
	CSSM_CSP_HANDLE cspHand,
	CFStringRef pwd,			// explicit passphrase, mutually exclusive with...
	bool verbose,
	unsigned loops)
{
	int 			ourRtn;
	
	for(unsigned loop=0; loop<loops; loop++) {
		{
			/* localize scope of coder for malloc test */
			P12Coder coder;
			CFDataRef cfd = CFDataCreate(NULL, pfx.Data, pfx.Length);
			ourRtn = 0;
			
			printf("...decoding...\n");
			try { 
				coder.setCsp(cspHand);
				coder.setMacPassPhrase(pwd);
				coder.decode(cfd);
			}
			catch(...) {
				printf("***decode error\n");
				return 1;
			}
			CFRelease(cfd);
			
			/* should just be able to re-encode it */
			printf("...encoding...\n");
			CFDataRef encPfx;
			try {
				coder.encode(&encPfx);
			}
			catch(...) {
				printf("***encode error\n");
				return 1;
			}
			writeFile("encoded.p12", CFDataGetBytePtr(encPfx),
				CFDataGetLength(encPfx));
			printf("...wrote %u bytes to encoded.p12\n",
				(unsigned)CFDataGetLength(encPfx));
			CFRelease(encPfx);
		}
		if(loops > 1) {
			fpurge(stdin);
			printf("CR to continue: ");
			getchar();
		}
		if(ourRtn) {
			return ourRtn;
		}
	}
	return ourRtn;
}
Example #22
0
int main(int argc, char const *argv[]) {
    char command, condition = 1;
    FILE *stockBase;
    struct stock thisStock;

    if (stockBase = fopen("stocker.dat", "r"))  {
        while (fread(&thisStock,sizeof(struct stock),1,stockBase) != NULL)
            gRecordNr = thisStock.recordNr;
        fclose(stockBase);
    }
    else
        gRecordNr = 0;


    puts("welcome to the stocker app!");
    while(condition)  {
        puts("A - list stocks");
        puts("B - add stock");
        puts("C - edit stock");
        puts("D - delete stock");
        puts("E - compare stocks");
        puts("Q - quit");
        putchar('\n');
        printf("type in command: " );
        fpurge(stdin);
        command = getchar();
        command = toupper(command);
        putchar('\n');

        switch(command)  {
            case 'A':
                ListStocks();
                break;
            case 'B':
                AddStock();
                break;
            case 'C':
                EditStock();
                break;
            case 'D':
                DeleteStock();
                break;
            case 'E':
                CompareStocks();
                break;
            case 'Q':
                condition = 0;
                break;
            default:
                puts("please enter valid input!");
                break;
        }
    }
    return 0;
}
Example #23
0
int main(void) {
    
    char cadena;
    /*int i;*/
    int numeros=0;
    int espacios=0;
    int caracteres=0;
    /*int longitud;*/
    
    printf("Inserta una cadena siendo el último carácter una punto:\n");
    fflush ( stdout );
    fpurge ( stdin );
    scanf("%c", &cadena);
    
    /*longitud = strlen(cadena);*/
    /*
     recorrer con un while buscando el final de la cadena:
     i=0;
     while (cadena[i] != '\0') {
     ...
     }
     que es lo mismo (siempre que tu cadena esté cerrada) si colocas simplemente:
     while (cadena[i]) {
     ...
     }
*/
    
    while(cadena != '.')
    {
        if((cadena >= 'A' && cadena <= 'Z') || (cadena >= 'a' && cadena <= 'z'))
        {
            caracteres++;
        }
        else
        {

                if((cadena >= '0' && cadena <= '9'))
                {
                numeros++;
                }
                if(cadena ==' ')
                {
                    espacios++;
                }
        }
        scanf("%c", &cadena);
    }

    printf("Números: %d\n", numeros);
    printf("Espacios: %d\n", espacios);
    printf("Carácteres: %d", caracteres);
    
    return 0;
}
Example #24
0
static void doPause(const char *prompt) {	
	if(prompt) {
		printf("%s. ", prompt);
	}
	fpurge(stdin);
	printf("Continue (n/anything)? ");
	char c = getchar();
	if(c == 'n') {
		exit(0);
	}
}
Example #25
0
void check_valid_input(int *input) {
    if (scanf("%d", input) != VALID_INPUT) {
        printf("\nInvalid input! Enter an integer value.\n\n");
// fpurge is only defined on BSD machines
#ifdef __linux__
        __fpurge(stdin);
#elif __APPLE__
        fpurge(stdin);
#endif
        *(input) = -1;
    }
}
int getCachedFields(TestParams *testParams)
{
	CSSM_RETURN		crtn;
	CSSM_HANDLE 	cacheHand1;
	CSSM_HANDLE 	cacheHand2;
	unsigned		fieldNum;
	unsigned		loopNum;
	CSSM_DATA		cert;
	
	for(loopNum=0; loopNum<testParams->numLoops; loopNum++) {
		if(testParams->verbose) {
			printf("getCachedFields loop %d\n", loopNum);
		}
		else if(!testParams->quiet) {
			printChar(testParams->progressChar);
		}
		
		/* get two cached certs */
		cert.Data = certData;
		cert.Length = certLength;
		crtn = CSSM_CL_CertCache(testParams->clHand, &cert, &cacheHand1);
		if(crtn) {
			printError("CSSM_CL_CertCache(1)", crtn);
			return 1;
		}
		crtn = CSSM_CL_CertCache(testParams->clHand, &cert, &cacheHand2);
		if(crtn) {
			printError("CSSM_CL_CertCache(2)", crtn);
			return 1;
		}
	
		/* grind thru the known OIDs */
		for(fieldNum=0; fieldNum<NUM_FIELD_OIDS; fieldNum++) {
			int rtn = checkOneField(testParams->clHand,
				cacheHand1, 
				cacheHand2,
				fieldOids[fieldNum]);
			if(rtn) {
				return 1;
			}
		}
		CSSM_CL_CertAbortCache(testParams->clHand, cacheHand1);
		CSSM_CL_CertAbortCache(testParams->clHand, cacheHand2);
		/* leak debug */
		#if	DO_PAUSE
		fpurge(stdin);
		printf("Hit CR to continue: ");
		getchar();
		#endif
	}	/* outer loop */
	return 0;
}
Example #27
0
int main( void ) {
    
char nombre[20];
int edad;
int dias;

printf( "Introduzca su nombre: \n");
fflush( stdout );
fpurge( stdin );
scanf( "%s", nombre );

printf( "Introduzca su edad: \n");
fflush( stdout );
fpurge( stdin );
scanf( "%d", &edad );

dias=edad*365;

printf( "Hola %s!, tienes %d dias de vida\n", nombre, dias );

return 0;
}
Example #28
0
void	xfpurge(FILE *stream)
{
#ifndef __FreeBSD__
  __fpurge(stream);
#endif
#ifdef __FreeBSD__
  if (fpurge(stream) == EOF)
    {
      xwrite(2, "fpurge failed\n", 14);
      exit(EXIT_FAILURE);
    }
#endif
}
Example #29
0
contato readContact()
{
    contato reg;

    printf("\nDigite o codigo: ");
    scanf("%d", &reg.codigo);
    printf("Digite o nome: ");
    fpurge(stdin);   // fflush(stdin)  // no windows
    fgets(reg.nome, sizeof(reg.nome), stdin);

    printf("Digite o telefone: ");
    fgets(reg.telefone, sizeof(reg.telefone), stdin);
    return reg;
}
Example #30
0
int main (void)
{
    char ch;
    int x, y;

    printf ("Please input a char: ");
    ch = getchar ();
    fpurge (stdin);
    printf ("Please input the coordinate to print: ");
    scanf ("%d%d", &x, &y);
    chline (ch, x, y);
    printf ("\n");

    return 0;
}