please dont rip this site

language ccpp cref PROBLEMS ascii2

/ ************************************************************************
 *
 * problem: Display an Ascii table. Fab version
 * Author:  M J Leslie
 * Date:    12-Mar-94
 *
 ************************************************************************/

#include <stdio.h>			/* printf, putchar, fopen, fclose */

					/* Function declarations	*/
int ascii(int);

main()
{
ascii('h');				/* ascii table in Hex		*/
ascii('d');				/* ascii table in decimal	*/
ascii('r');				/* test invalid option		*/
}

/*************************************************************************
	O/P an ascii table 						
	Parms:	int - O/P type 'h' hex  
			       'd' decimal
			           any other value not allowed.
	Return codes: 0 = OK
		      1 = Invalid parms passed.				
*************************************************************************/

#define LINEBREAK 8
#define FALSE     0
#define TRUE      1

int ascii(int type)
{
int  ascii, inc=0;				
char ch;				/* 'ascii' in char format.	*/
char format[10];			/* Format statement for printf  */

					/* Are we to O/P in hex or decimal?
					   h - hex
					   d - decimal */
switch(type)
   {
   case 'h' : strcpy(format,"%02X %c  ");	/* hex     */
		break;
   case 'd' : strcpy(format,"%03d %c  ");	/* decimal */
		break;
   default :  printf("\n Function syntax:\n");    /* error   */
              printf("    ascii('h') for hex O/P\n");
              printf("    ascii('d') for decimal O/P\n");
	      return(1);
   }
					/* O/P a table heading		*/
printf("\n\tAscii table");
printf("\n\t-----------\n\n");

					/* O/P the table		*/
for (ascii=0; ascii<=127; ascii++) 	/* loop through the Ascii codes */
   {
					/* Check that the character is 
					   printable...			*/	
   ch = ascii;
   if ( isprint(ch) == FALSE )
      ch = ' ';				/* Replace with ' ' if not printable */

   printf(format, ascii, ch);  		/* O/P numeric and character format */
   
					/* count # of codes O/P and insert
					   L/F when required		*/	
   if ( ++inc%LINEBREAK == 0 ) printf("\n");
   }
return(0);
}


file: /Techref/language/ccpp/cref/PROBLEMS/ascii2.c, 1KB, , updated: 1997/4/21 09:53, local time: 2012/5/23 21:42,
TOP NEW HELP FIND: 
38.107.179.230:LOG IN

 ©2012 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE! / 

<A HREF="http://www.piclist.com/tecHREF/language/ccpp/cref/PROBLEMS/ascii2.c"> language ccpp cref PROBLEMS ascii2</A>

Did you find what you needed?

 
Stepper motors CAN be smooth!
And stepper controllers can be strong and cheap. Roman Black's Linistep stepper controller kits:
o 18th microstep
o Linear smoothing
  o Open source
o Full kit $25!
 
Feel the NEED for SPEED?
Ubicom SX18 thru SX52, PIC 16c5X compatibile, 50 to
75 MIPS microcontrollers!
Now US customers can buy the Excellent SXDev from SXList.com
for $150 + $15 import fee + s&h (~ $180 total+tax in CA)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .