File: dkf5kRange.c

package info (click to toggle)
splint 3.1.2.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 12,908 kB
  • ctags: 15,816
  • sloc: ansic: 150,306; yacc: 3,463; sh: 3,426; makefile: 2,217; lex: 412
file content (18 lines) | stat: -rw-r--r-- 412 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*dkf5k*/
#include <stdlib.h>
#include <stdio.h>
 
int main()
{ 
  char buffer[12] = "hello world";
  int i;
  printf("Enter the character you want: ");
  scanf("%i", &i);
  if ( i >= sizeof(buffer))
    {
      fprintf(stderr, "Error: %i is greater than or equal to the range which is %i", i, sizeof(buffer));
      exit(0);
    }
  printf("You asked for character %i which is %c", i, buffer[i]);
  return 0;
}