I have problem that when I run my program it does just take for the array everything that is on first input instead of second one and I just cant figure out why. To specify if i write in console 1 letter it does first part ok, but then print this weird ╠╠╠╠╠╠╠╠╠ (lot of it) and second task then just take this like input. This task is supposed to take string (even with spaces) and count bid/small letters, numbers and other. Can somebody pls tell me what I did wrong? Thanks for help and stay safe
#include<stdio.h>
#include <string.h>
int main()
{
char z;
int B = 0, s = 0, n = 0, else = 0;
printf("Enter character:");
scanf_s("%c", &z, 1);
if (z >= 'A' && z <= 'Z')
printf("Big letter\n");
else if (z >= 'a' && z <= 'z')
printf("small letter\n");
else if (z >= '0' && z <= '9')
printf("number\n");
else
{
printf("else\n");
}
char something[50];
printf("Enter string:");
scanf_s("%50[^\n]", str, 50);
printf("Your name is %s", something);
int space = 0;
int len = 0;
for (int i = 0; something[i] != '\0'; i++)
{
if (something[i] == ' ')
{
space++;
}
else
{
len++;
}
}
for (int i = 0; i <= len; i++)
{
if (something[i] >= 'A' && something[i] <= 'Z')
{
B++;
}
else if (something[i] >= 'a' && something[i] <= 'z')
{
s++;
}
else if (something[i] >= '0' && something[i] <= '9')
{
n++;
}
else
{
other++;
}
}
printf("Your input %s contains:\nB=%d s=%d n=%d else=%d\n", something, B, s, n, other);
return 0;
}