i have a doubt how can we use string in matrices for examples a=rohinn a=rithish how to do this????

## Recommended Answers

start with something like this:

`````` char array= { "one", "two", "three" };
printf("%s, %s, %s\n", array, array, array);
``````

for user input you can use a loop for every index

If a and a are both null-terminated strings, then you have to call strcmp() to check of the two strings are the same. The following will produce a two-dimensional array of strings that contain up to 40 characters each.

``````char a;
strcpy(a,"Hello");
strcpy(a,"World");

if( strcmp(a, a) == …``````

## All 5 Replies

start with something like this:

`````` char array= { "one", "two", "three" };
printf("%s, %s, %s\n", array, array, array);
``````

for user input you can use a loop for every index

If a and a are both null-terminated strings, then you have to call strcmp() to check of the two strings are the same. The following will produce a two-dimensional array of strings that contain up to 40 characters each.

``````char a;
strcpy(a,"Hello");
strcpy(a,"World");

if( strcmp(a, a) == 0)
{
printf("Both strings are the same\n");
}
``````

no can we use only if we predefine values like this

char array= { "one", "two", "three" };
cant we do like this

``````printf("enter the limit: ");
scanf("%d%d",m,n);
printf("enter the characters: ");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%c"a[i][j]);
}
}
``````

yes you can do it like that for single character user input

isn't the code you need similar to the program you posted in this thread. If so if you imply my suggestion of using a 2d array for the variable on the code there then you'll have char array (string) values from user input

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.