All pastes #258536 Raw Edit

Ass #3, Pointers.

public c v1 · immutable
#258536 ·published 2006-11-26 16:46 UTC
rendered paste body
// Assignment 3// // Lists characters from the memory starting from a given address// until an end address.// No address control so be careful.//#include <stdio.h>int main(void){ char  i = 'a';     // A test assignment // char *sptr; char *eptr; FILE *ofile; char filename[30]; sptr = &i ;        // sptr points to i, in order to get an example address   // printf("--------------------------------------------------------- \n"); printf("Example address, using a simple character assignment (%c) \n",i); printf("Example position: %p \n\n",sptr); printf("Enter a starting address\n"); scanf("%x",&sptr); // Read start address //  printf("Enter an ending address\n"); scanf("%x",&eptr); // Read end address   // printf("Please type in the name of the file you want the output\n"); scanf("%s",filename); ofile = fopen (filename,"w"); for (; sptr <= eptr; sptr++){  // Move pointer until it reaches the end po. //		if (isgraph(*sptr)) {	 fprintf(ofile,"%c", *sptr);  // Printing only readable characters //	} } fclose(ofile); return 0;}