How to separate what is introduced?

0
#include<stdio.h> 
#include<stdlib.h>
#include<conio.h>
#include<ctype.h>
#include<string.h>

char cad[15],ch,numeros[15];
int i=0,num=0,letra=0,puntos=0,espacios=0,j=0;

void identificar(){
    printf("Ingresa una cadena: ");
    gets(cad);

    for (i=0; i<=14; i++){

    if (isdigit(cad[i]))
    num++;

    if (isalpha(cad[i]))
    letra++;

    if (ispunct(cad[i]))
    puntos++;

    if (isspace(cad[i]))
    espacios++;

    }

    printf("\nNumeros: %i %c",num, numeros[15]);
    printf("\nLetras: %i",letra);
    printf("\nSignos de puntuacion: %i",puntos);
    printf("\nEspacios: %i",espacios);

}

int main() 
{ 
do{
   system("color A");
   system("cls");
   printf("a- Identificar  \ni- Salir \n Ingresa una opcion: ");
   scanf("%c",&ch);
   fflush(stdin);
   if(ch>=65 && ch<=90)
    ch+=32;

   switch (ch)
   {
   case 'a':
   identificar();
   getch();
   fflush(stdin);
   system("cls");
   break;

   case 'b':

   getch();
   fflush(stdin);
   system("cls");
   break;

   case 'c':

   getch();
   fflush(stdin);
   system("cls");
   break;


   default:
   fflush(stdin);
   system("cls");
   printf("Esa opcion no esta disponible! \n \n \a \a"); 
   system("pause");     
   system("cls");

   }

    } while(ch == 'i');
   return 0;

}

What I already do is count the letters, numbers, points and spaces, but I want to show them in separate lists.

    
asked by Erick Octavio González Aceves 22.11.2017 в 23:01
source

1 answer

0

The escape character \ n serves to make a line break to the line below Add a \ n to the end of the printf and not to the beginning

printf("Numeros: %i %c\n",num, numeros);
printf("Letras: %i\n",letra);
printf("Signos de puntuacion: %i\n",puntos);
printf("Espacios: %i\n",espacios);

Additionally I corrected two errors in the code

    
answered by 22.11.2017 в 23:32