[c] Index

Viewer

  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.     char sentence[50] = " ";
  6.     int index;
  7.  
  8.     printf("Write a sentence? ");
  9.     fgets(sentence,50,stdin);
  10.     printf("Look up character at index? ");
  11.     scanf("%d", &index);
  12.  
  13.     printf("In \"%s\" index %d is the character '%c'.", sentence, index, sentence[index]);
  14.  
  15.     return 0;
  16. }

Editor

You can edit this paste and save as new:


File Description
  • Index
  • Paste Code
  • 30 Nov-2022
  • 338 Bytes
You can Share it: