ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
In your original displayWords function you were trying to regenerate a new set of words which would be different then your other function getFourRandomWords. To display the four words just use a loop:
Code:
// word to be displayed/searched by the user
void displayWords(){
int loop;
for(loop = 0; loop < 4; loop++)
printf("%s ", fourWords[loop]);
printf("\n");
}
In your other posts about not finding the words just call the display puzzle function to see the results after you place the works to see where they are located since the empty locations will be *. In your place word functions your checking to see if there is an existing letter but not the entire word so sometimes you might see just a random letter.
In your original displayWords function you were trying to regenerate a new set of words which would be different then your other function getFourRandomWords. To display the four words just use a loop:
Code:
// word to be displayed/searched by the user
void displayWords(){
int loop;
for(loop = 0; loop < 4; loop++)
printf("%s ", fourWords[loop]);
printf("\n");
}
In your other posts about not finding the words just call the display puzzle function to see the results after you place the works to see where they are located since the empty locations will be *. In your place word functions your checking to see if there is an existing letter but not the entire word so sometimes you might see just a random letter.
Thank you!
it worked. And your explanation coupled with the example was much easier to understand.
(i didn't even remember that I had a char fourWords...)
I guess I have had enough C lessons for this week and my old(ish) brain feels like it has climbed the Everest. I will spend the next few weeks/months trying to learn how the user/program will input/take the coordinate of each word and perhaps highlight it if correct. Any pointers on what I need to look up?
Once more, thank you everyone on this. Now i remember why I chose the Linux community and joined LinuxQuestions
One fairly simple way to highlight would be to use ANSI escape code sequences. You can change the text and background colors.
Code:
printf("\033[1;31m"); // change text color to red
printf("%c ", puzzle[i][j]); // print puzzle letter in red
printf("\033[0m"); // reset color back to default
One fairly simple way to highlight would be to use ANSI escape code sequences. You can change the text and background colors.
Code:
printf("\033[1;31m"); // change text color to red
printf("%c ", puzzle[i][j]); // print puzzle letter in red
printf("\033[0m"); // reset color back to default
The difficult part is figuring a way to keep track which letters were selected.
YAY! Not bragging my (non)extensive coding/web-search skills {sarcasm} but I had done it all on my own
Code:
// word to be displayed/searched by the user in red colour
void displayWords(){
int loop;
printf("\033[1;31m");
for(loop = 0; loop < 4; loop++)
printf("%s ", fourWords[loop]);
printf("\n");
}
//Create a user-interactive menu in normal/console colours
void mainMenu()
{
printf("\033[0;32m");
char menuChoice;
do
{
........
I only wanted to color the words and not the entire puzzle, console colours are more 'catching'!
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,800
Rep:
Quote:
Originally Posted by however
I wonder whether people forget the meaning of 'beginner' once they specialize on a subject whether it being medicine or feeding chicken.
Agreed. Back when I was a TA (in a previous life) I initially found it difficult to see problems the same way as a newcomer to the subject was seeing them.
I sometimes wonder if it wouldn't make sense for some fora to have a "newbie" sub-forum where the real beginners' questions can be posted. Or perhaps "Newbie" could have all those sub-fora -- Newbie-Software, Newbie-Hardware, etc. -- rather like those under "Distributions". I suspect, though, that making things that fine-grained might be a pain for the moderators to manage.
Agreed. Back when I was a TA (in a previous life) I initially found it difficult to see problems the same way as a newcomer to the subject was seeing them.
I sometimes wonder if it wouldn't make sense for some fora to have a "newbie" sub-forum where the real beginners' questions can be posted. Or perhaps "Newbie" could have all those sub-fora -- Newbie-Software, Newbie-Hardware, etc. -- rather like those under "Distributions". I suspect, though, that making things that fine-grained might be a pain for the moderators to manage.
Cheers...
Although it sounds like an excellent idea, it has its drawbacks. The main one being that it will mostly be newbies-halping-newbies (like the blinding leading the deaf) and real help would be hard to get as well as real learning opportunities.
Perhaps the issue is more at personal/individual level. I know there tens , if not hundreds of hard-core developers in this forum and they hardly ever reply or engage in any of my questions; and, that's absolutely fine. I really understand and don't expect their involvement.
But then having the so called, I-know-it-all, who prefers to type an A4 size of lines, explaining how something should be, to a beginner who took almost 3months to type (and copy&paste) 100 lines of whatever it's really showing how either they do-not-know-anything-at-all or they are very arrogant teachers. My analogy would be: trying to teach university level to primary school pupils.
There is never a bad student, only bad teachers (I love this phrase, I just don't remember who is it from)
TA -Technical Assistant: often a person doing an advance degree (Masters or PhD) who assists in the undergrad 'lab' for money.
BTW, I also agree with dumping the IDE (for now anyway).
You're trying to learn >1 tool at the same time that way and you don't always know which is which.
Simplify, simplify
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.