-1
I want to modify standard phrases from a theoretical game. For example, the game has the phrase "Choose a command" and, over a given state, I would like to exchange all letters "o" and "a" for a @.
For this, I thought of implementing a character array,
lines[100][500], which can store 100 500-character phrases.
I want to assign to the lines[1] "Choose an action", lines[2] "You cannot go there", etc.
And, to do what I want to do, given that the player is in such a state, I would use sscanf in sentence[x][] and go through the whole sentence[x][i], with i going from 0 to strlen phrase[x].
However, I’m not able to assign and I don’t know how to print these sentences.
The first problem is not knowing how to include ' 0' at the end of a string typed within the program. At the same time %s should work until you find the first 0 in the memory bin, and it is printing only a random character in the program below:
#include<stdio.h>
int main (){
char falas [100][500];
falas[1][0] = "Seja bem vindo ao meu jogo";
printf("%s", falas[1]);
}
Well, then it gets a little complicated because there’s a lot of things you’re not able to do, so we’ll have to do all the code for you, it would be better to face one problem at a time.
– Maniero
Just assigning strings to lines of a character array would help a lot.
– abcson
How many sentences will there be?
– Maniero