logoISU  

CS256 - Principles of Structured Design

Fall 2021

Displaying ./code/sternflCode/str3.c

#include<stdio.h>
#include<string.h>
//make our own strlen function
int ourStrLen(char *s) {
   int i=0;
   while (s[i]!=0)
     i++;
   return i;
}

int main() {
  printf("Please enter a string ");
  char str[100];
  scanf("%s", str);
  printf("%s\n", str);
  printf("%d\n", strlen(str) );
  for(int i=0; str[i]!=0; i++)
    printf("%c\n", str[i]);
  printf("ourstrlen function: %d\n", ourStrLen(str));
  return 0;
}