Chuỗi C. Bài tập-7 có lời giải
Viết chương trình bằng C để đếm tổng số chữ cái, chữ số và ký tự đặc biệt trong một chuỗi
Giải pháp mẫu
Mã C
#include
#include
#include
#define str_size 100 //Declare the maximum size of the string
void main[]
{
char str[str_size];
int alp, digit, splch, i;
alp = digit = splch = i = 0;
printf["\n\nCount total number of alphabets, digits and special characters :\n"];
printf["--------------------------------------------------------------------\n"];
printf["Input the string : "];
fgets[str, sizeof str, stdin];
/* Checks each character of string*/
while[str[i]!='\0']
{
if[[str[i]>='a' && str[i]='A' && str[i]='0' && str[i]