-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprac14.c
More file actions
34 lines (30 loc) · 679 Bytes
/
prac14.c
File metadata and controls
34 lines (30 loc) · 679 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
33
34
//find frequency of characters using pointers
#include<stdio.h>
#include<string.h>
void findfre(char *ptr,int n);
int main(){
char str[1000];
gets(str);
int l=strlen(str);
char *p=str;
findfre(p,l);
}
void findfre(char *ptr,int n){
int count;
for(int i=0;i<n;i++)
{
count=0;
if(*(ptr+i)!='\0')
{
for(int j=i+1;j<n;j++)
{
if(*(ptr+i)==*(ptr+j))
{
*(ptr+j)='\0';
count++;
}
}
printf("num= %c and f=%d\n", *(ptr+i),count+1);
}
}
}