字符数组被称为字符串。
以下是声明数组的声明方式 −
char stringname [size];
例如 − char string[50]; 长度为50个字符的字符串
char string[10] = { ‘H’, ‘e’, ‘l’, ‘l’, ‘o’ ,‘\0’}
char string[10] = "Hello":;
访问− 有一个控制字符串 "%s" 用于访问字符串,直到遇到 ‘\0’。
查找给定字符串中字符的最小出现次数的逻辑如下 −
for(i=0; i Copy after login
以下是查找字符串中出现次数最少的字符的 C 程序。
#include#define SIZE 100 // Maximum string size #define CHARS 255 // Maximum characters allowed int main(){ char string[SIZE]; int frequency[CHARS]; int i = 0, minimum; int value; printf("Enter the string: "); gets(string); for(i=0; i
Copy after login
当执行上述程序时,会产生以下结果 -
Enter the string: tutorialspoint Minimum occurrence character is 'a' = 1 times.
The above is the detailed content of C program: Find the minimum number of occurrences of a character in a string. For more information, please follow other related articles on the PHP Chinese website!