I want to print each first character of a List of Array in upper case using C.

For example, if I have Array of these elements

char *d[] = {"water", "salt", "sugar", "milk", "soda"};

I want my function to print them like this

Water Salt Sugar Milk Soda

I will appreciate any help.


Thank

Start by writing some code that outputs each word.

Then change the code to add capitalization.

1

[edit] If you're going to remove a message, leave a useful message in it's place. Like "Duplicate removed". [/edit]

bellow i tried to solve your problem bt the problem i m facing that i cant count the number of words in the array ..so i passed the number manually in line 10..if you can solve it pls inform

//Pirateā„¢
#include<stdio.h>
#include<stdlib.h>

void print_words(char *str[],int m);

void main()
{
        char *d[]={"water","salt","suger","milk","soda"};
	print_words(d,5);
}

void print_words(char *str[],int m)
{
	char *temp;
	
for(int i=0;i<m;i++)
	{
		int j=0;
	
		temp=str[i];

		while(*temp)
		{
			if(j==0)
				printf("%c",toupper(*temp));
			else
				printf("%c",*temp);
			j++;
			temp++;
			
		}
		printf(" ");
		
	}
	
}
commented: Do NOT try to solve problems for people here. Help them solve the problems themselves -2