//hangman word is my text file which include words
i use this code to generate a random number corresponding to a word in our file
and works fine calculate and generate a right number the problem is here when i want to select the appropriate word from our file
i wrote this code and appear this wrong message "awk: 2: unexpected character '.'"
Finally i want a help how to replace a character who read from keyboard with -
i Forgot to write this code how to split the word to table using this code
i use this code to make the - - - - -
any idea how to replace the '-' with the right character with command substr or something else
i use this code to read one character
i don't finish the code of while because i didn't know how to replace the '-' with the right character but the most important is to solve the error
Hi, there should be a space between ' and $wordlist
As to the ---
You means something like this?
Alternatively:
and if you use bash or ksh you could also use:
I am not sure what you mean with "the right character"
Last edited by Scrutinizer; 12-16-2009 at 07:54 PM..
i have read many books and i read yet the last i try to study is The Complete Reference Unix" from Obserne
one thought is wrote this code to replace the '-' with right character is using the substr
is using this code to calculate the length
do you believe that may work or what you recommend to chance in this code to run correctly
---------- Post updated at 07:05 PM ---------- Previous update was at 06:58 PM ----------
using this code i split the word to a table
using this code i replace the characters with - - -
for example if the word was bedroom with this code appear - - - - - - -
i want to read a character using this command
and if this character included for example to bedroom display this character for example
the word is :bedroom
script appear: ------- 7- depends on word length
while i read charact: press e
i want the script appear this -e----m
with this code the problem is that in
1st loop guessed was e
display that -e----
2nd loop when guessed was d
display that --d---
and the desire sesult was -ed----
any idea???
---------- Post updated at 08:28 PM ---------- Previous update was at 08:18 PM ----------
Quote:
Originally Posted by Scrutinizer
Something like this:
can you explain me this 2 lines what are you doing?
using this code if [ -n "$char" ] any char press the lifes decrease we want to decrease when the guessed is wrong any idea
and why use this guessed="$guessed$char"
can i ignore this line guessed="$guessed$char"
and last line wrote this echo $word|sed "s/[^$char]/-/g"
why use 2 (( here $((lives -1)) and why $ is out;
sorry for my question but i want to learn i think stupid to write somenthing don't understanding maybe i need to use many of commands in the future
In Addition the decrease must doing when i press wrong guess
---------- Post updated at 10:31 PM ---------- Previous update was at 08:28 PM ----------
one though is to split the word to a table an with for i check if char is not included to table decrease the lifes
for example in c language i can write this
for (i=1;i<=sizeof(tablep);i++)
{
if (char != tablep[i])
lives--;
}
Hello everyone, im just having some problem forming a script for a hangman script. The question states:
The object this excercise is for u to write a script that emulate the classic game hangman. The object of this game is for a user to try and guess a word which has been generated by the... (1 Reply)