Question 1)
#include <iostream.h>
void main (void){
char word [50];
cin >> word;
for (int i=0;word!='ENTERLETTERHERE';i++){
cout << word << " ";
}
}
there should be some letter or maybe a \letter that, when replacing the ENTERLETTERHERE part of this code, works. What I want to do is this: If I type in Bruno, the output should be "B r u n o". It stops the loop right after the last letter.
-----------------------------
Question 2)
struct stcPalavra{
char item [50];
struct stcPalavra *esq, *dir, *linhas;
};
// cutted code
void classIndice :: insere (char elemento [], stcPalavra * pont){
if (pont == NULL){
pont->item = elemento;
pont->esq = pont->dir = NULL;
}
else if (strcmp(elemento, pont->item) < 0) insere (elemento, pont->esq);
else if (strcmp(elemento, pont->item) > 0) insere (elemento, pont->dir);
else cout << "Elemento ja existente!\n";
};
The problem in this code is in the line: "pont->item = elemento"... the compiler says that it cannot convert a char[] to a char[50] (that's why I made the first question). Is there a way of doing this without having to make a loop that copies letter to letter until all the word is copied?
Thanks for your time,
Bruno Feu
PS: The code is in Portuguese, I hope that is not a problem to you guys.
#include <iostream.h>
void main (void){
char word [50];
cin >> word;
for (int i=0;word!='ENTERLETTERHERE';i++){
cout << word << " ";
}
}
there should be some letter or maybe a \letter that, when replacing the ENTERLETTERHERE part of this code, works. What I want to do is this: If I type in Bruno, the output should be "B r u n o". It stops the loop right after the last letter.
-----------------------------
Question 2)
struct stcPalavra{
char item [50];
struct stcPalavra *esq, *dir, *linhas;
};
// cutted code
void classIndice :: insere (char elemento [], stcPalavra * pont){
if (pont == NULL){
pont->item = elemento;
pont->esq = pont->dir = NULL;
}
else if (strcmp(elemento, pont->item) < 0) insere (elemento, pont->esq);
else if (strcmp(elemento, pont->item) > 0) insere (elemento, pont->dir);
else cout << "Elemento ja existente!\n";
};
The problem in this code is in the line: "pont->item = elemento"... the compiler says that it cannot convert a char[] to a char[50] (that's why I made the first question). Is there a way of doing this without having to make a loop that copies letter to letter until all the word is copied?
Thanks for your time,
Bruno Feu
PS: The code is in Portuguese, I hope that is not a problem to you guys.