Because Daniweb has rules. Specifically: "Do provide evidence of having done some work yourself if posting questions from school or work assignments"
Your problem is clearly a basic exercise intended for learning, and thus constitutes homework. Therefore we expect a certain measure of effort on your part before offering help. If we did the work for you, you'd learn nothing.
You're testing z[i], which is an array rather than a string. Try this instead:
for (i = 0; i < 3; i++)
for (j = 0; z[i][j] != '\0'; j++)
if (z[i][j] == 'a')
Note that the outer loop only goes through the number of strings you actually input, this is important if you don't initialize all of the strings to be blank. The inner loop only searches the contents of the string (which ends with a '\0' character in a valid string). Finally, the condition checks the characters in each string as you're using an array of arrays of char.
All strlen does is search for a '\0' character, so it's more efficient to simply do that yourself as in my example in a previous post. This is assuming the string is valid in the first, place, of course. ;)
int n, count = 0;
printf("Enter the no of characters present in an array \n ");
printf(" Enter the string of %d characters \n" , n);
while (count < n)
printf(" %c = %d\n", string[count], string[count] );
++ count ;
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
OK, so HostGator for some reason no longer allows gcc/g++ access unless you have a Designated Server account, which is a lot of money to spend just to compile my "Hello World" program. Thus I figured I'd compile at home, then upload. Program is your regular old bare-bones Hello World ...