Return Character Array

Returning character arrays from a function in C.

Character arrays in C.

Date Created:Sunday March 04th, 2007 06:35 PM
Date Modified:Saturday August 02nd, 2008 02:45 PM

#include <stdio.h>

char *GetNoteName();

int main()
    printf"%s\n"GetNoteName() );
    return 0;

char *GetNoteName(void) 
        static char notes[12] = "A#BC#D#EF#G#";
        return notes;

#include <stdio.h>

void enternumber(int *x);
void printint(int x);
char *return_note_name(int x);

int main()
    int sizenote;
    return 0;

char *return_note_name(int x)
    static char note_name[12][6] = {     
    return note_name[x%12];

void enternumber(int *x) {
    printf("Enter a number between 1-88\n");

void printint(int x) {

Download: chars.c 215 B
Download: chars2.c 658 B

Please login or Click Here to register for downloads
Creative Commons License
Return Character Array by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at
Permissions beyond the scope of this license may be available at