Initialize a local variable to known value. - C Language Basics

C examples for Language Basics:Variable

Introduction

For example, the following program prints the number 10 ten times:

Demo Code

#include <stdio.h>

void f(void);

int main(void)
{
    int i;// w  w w.  j  a  v a 2  s .  c  o  m

    for (i = 0; i<10; i++) f();

    return 0;
}

void f(void)
{
    int j = 10;

    printf("%d ", j);

    j++; /* this line has no lasting effect */
}

Related Tutorials