0
I am doing a code task and need to convert a string, for example:
123+*
In an`(array) vector of type:
1 2 3 + *
Does anyone know how I could do this in C? I’m a beginner and would like to learn. Thanks in advance.
0
I am doing a code task and need to convert a string, for example:
123+*
In an`(array) vector of type:
1 2 3 + *
Does anyone know how I could do this in C? I’m a beginner and would like to learn. Thanks in advance.
1
A string/word is nothing less than a vector of characters, that is, its string is already an array. You can use it with such a:
char minha_string = "123+";
minha_string[0] = '2'; // Alterando o valor do 1 para o 2, agora a string é 223+
If you want to create another array that has the values of your string then you can use the string library. h and use the function strcpy(vector 1, veotr2). Another solution:
for(int i = 0; i < QUANTIDADE_CARACTERE_DA_STRING_AQUI; i++)
{
vetor1[i] = vetor2[i];
}
Browser other questions tagged c string
You are not signed in. Login or sign up in order to post.
I have a string in C is an array of characters plus the terminator character ' 0', so its string "123+" is in memory as '1', '2', '3', '+', '', '\0'.
– anonimo