Hello guys. I have a matrix with char.
#define MAX_CHAR 128
#define MAX_SIRURI 10
char siruri[MAX_SIRURI][MAX_CHAR];
I must read the number of strings ( n ), and after that, to go through each string. I must read each string, after that, to show it, and to find for each one, the number of characters, the number of sentences and how many 'a' & 'A' got the sentence.
Here is the whole program
#include <stdio.h>
#include <conio.h>
#define MAX_CHAR 128
#define MAX_SIRURI 10
void main(void)
{
int n, k, i, j,
nrcuv[MAX_SIRURI] = {0},
nrAa[MAX_SIRURI] = {0},
nrchar[MAX_SIRURI] = {0};
char siruri[MAX_SIRURI][MAX_CHAR];
do
{
printf("How many strings do you want ?\n");
scanf("%d", &n);
}
while(n > MAX_SIRURI || !n);
for(i = 1; i <= n; i++)
{
printf("Give string %d: \n", i);
nrcuv[i] = 1;
gets(siruri[i]); // read string[i]
printf("\The string is: %s\n\n", siruri[i]);
for(j = 0; siruri[i][j]; j++) nrchar[i]++; // the number of characters
for(j = 0; siruri[i][j]; j++) // the numbers of 'a' & 'A', the sentences
{
if(siruri[i][j] == 'a' || siruri[i][j] == 'A') nrAa[i]++;
else if(siruri[i][j] == ' ') nrcuv[i]++;
}
}
getch();
}
And here is the problem ... :
- i read the number of strings ( n )
- and when the program enters in for, it skips the first string ...
- here is the result: (after i read n ) http://img852.imageshack.us/img852/144/errorm.png