0
I have a string vector(palavras[x][y]
), I can read every word that will be an element of the vector, but I cannot print any of these stored words.
printf("%s",palavras[a][b]),
doesn’t work.
Here are my attempts:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char nomes[1][15];
int i;
scanf("%s",&nomes[0][15]);
scanf("%s",&nomes[1][15]);
printf("%s",&nomes[0][15]);
// for(i=0;i<=15;i++){
// printf("%c",nomes[0][i]);
// }
system("PAUSE");
return 0;
}
The for
commented also did not work. How can I proceed?
You want a vector with only one string, which means he’ll only have one element with a string up to 14 characters? If it is more than one, is it always 2? You need to use a loop for some reason or it can be the simplest way?
– Maniero
he counts from 0 then would be 2 strings and 16 characters, words[0][15] = 'his' ; words[1][15]='comment'. I would like the simplest way to write any of these vectors on the screen.
– Gustavo Viana
I need a method for an n string array.
– Gustavo Viana
I need to print some of these strings.
– Gustavo Viana
Is there a reason you are trying to print string characters one by one using
%c
, instead of printing the whole string with%s
?– Isac
I left the string fixed, and the string characters would vary until the string is finished, in the for loop. But it also didn’t work.
– Gustavo Viana
but what I want is to print the whole string.
– Gustavo Viana