Access an array in function without changing it - C Function

C examples for Function:Function Parameter

Description

Access an array in function without changing it

Demo Code

#include <stdio.h>
#include <ctype.h>

void print_upper(char *string);

int main(void)
{
   char s[80];/*w w w  .  ja  va  2 s  .  co  m*/

   printf("Enter a string: ");
   gets_s(s);
   print_upper(s);
   printf("\ns is unchanged: %s", s);

   return 0;
}

void print_upper(char *string)
{
   register int t;
   for (t = 0; string[t]; ++t)
      putchar(toupper(string[t]));
}

Related Tutorials