forked from CPRO-Session1/Assignment4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstrings.c
More file actions
32 lines (29 loc) · 642 Bytes
/
strings.c
File metadata and controls
32 lines (29 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* Matthew Danielson
* 7/4/16
* strings.c
* returns character frequency
*/
#include <stdio.h>
#include <string.h>
int main(){
printf("How long wil your string be?");
int length;
scanf("%d", &length);
char chars[length+1];
printf("Please enter a string:");
for(int x= 0; x< sizeof(chars); x++)
scanf("%c",&chars[x]);
int sum;
for(int x = 1; x<sizeof(chars)-1; x++){
sum = 1;
for(int y = 0; y< sizeof(chars); y++){
if(chars[x] == chars[y] && x !=y){
sum ++;
chars[y] = 0;
}
}
if((chars[x]> 65 && chars[x] < 90) ||( chars[x] >97 && chars[x] <122));
printf("%c: %d \n", chars[x], sum);
}
return 0;
}