Skip to content

Instantly share code, notes, and snippets.

@SametSahin10
Created March 20, 2018 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SametSahin10/8e3686840cbe5b94d921479fdc2e5b0e to your computer and use it in GitHub Desktop.
Save SametSahin10/8e3686840cbe5b94d921479fdc2e5b0e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char name[50];
int numberOfElementsOfArray;
printf("Enter your name: \n");
fgets(name, 50, stdin);
int numberOfElements(char array[]);
numberOfElementsOfArray = numberOfElements(name[]);
return 0;
}
int numberOfElements(char array[]) {
int i;
for (i = 0; array[i] != '\0'; i++) {
//Calculates the number of elements in a given array.
}
return i; // i = numberOfElements
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment