All pastes #640597 Raw Edit

Someone

public text v1 · immutable
#640597 ·published 2007-07-31 14:47 UTC
rendered paste body
#include <stdio.h>
#include <stdlib.h>

/* Main function starts here */
int main()                         
{
	int choice;
	

        /* Menu */

        printf("\n--------ASCII chart program--------");
        printf("\n\n1. ASCII to text");
        printf("\n\n2. Text to ASCII");
        printf("\n\n3. Quit");
  
  	printf("\nEnter choice : ");
        scanf("%d", &choice);

       /* switch case starts here */
       switch(choice) { /* Choose the options now */
           
          case 1 : 
	     asciitotxt() ;
             break;
 
	  case 3 :
	     exit(1);

	  default :
	     printf("Invalid choice\n");
	     break;
       } /* switch case ends here */

       getchar();

       return 0;
}
/* Main function ends here */

int asciitotxt()                  /* Converts ASCII to plain text */
{
	int txt;
        char again[] = "y";
        
        
	/* Infinite loop starts here */
	while(1) {
	   
	      printf("\nASCII to text : ");
              scanf("%d", &txt);
              
	      printf("\nASCII %d is %c\n", txt, txt);

	      
	      printf("Do you want to continue : ");
	      fgets(again, sizeof(again), stdin);
	      
	      /* if starts here */
	      if(strcmp(again,"n") == 0) {
		      printf("Press any key to exit : ");
		      fgetc(stdin);
		      exit(1);
	      } 
	      /* if ends here */
	      
	}

	return 0;
}