Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #define MAX_LENGTH 80
  3. /*Calculates a string’s length using pointers.*/
  4. int my_strlen (char *s)
  5. {
  6. char *p = s;
  7. while (*p) p++;
  8. return p - s;///?השורה הזו לא פוגעת בספירה? היה מספיק לגמור את הקוד בשורה שלפניה?
  9. }
  10. void main()
  11. {
  12. char str[MAX_LENGTH];
  13. int len;
  14. printf("Enter a string:");
  15. gets(str);
  16. len = my_strlen(str);
  17. printf("The lenght of the string %s is %d \n",str,len);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement