This is a simple hangman game that I wrote using my beginner python skills. Though this game is playable, there must be lots of things I must've been doing wrong or the methods I'm using here may be not so pythonic. So I want some suggestions on how to improve this game.
The 'wordsdict.pkl' file contains a pickled dict with words as keys and meanings as their values.

e.g. {'word': 'its meaning'}

[QUOTE][CODE]fflush(stdin); //clear the buffer???![/CODE][/QUOTE]Don't use [ICODE]'fflush'[/ICODE] with [ICODE]'stdin'[/ICODE],[URL="

If you're using the variable val just to do this:[QUOTE][CODE]mov [val], ax
add si,val[/CODE][/QUOTE]then there's no need to do so,just do it directly
[CODE]add si,ax[/CODE]
It's quite difficult to understand what you're trying to do, the information provided here is too little(not enough) and as far as your sample code is concerned, syntactically it's fine.
Here's an example, I hope this will help .
suppose there's a string defined as
[CODE]string db "ABCDEFGH",'$'[/CODE]
and it's characters can be accessed like this
[CODE]mov bx,offset string
mov al,[bx+si];al = "A"
add si,02
mov al,[bx+si];al="C"[/CODE]
or like this[CODE]mov al,[string+si];al="A"
add si,02
mov al,[string+si];al="C"[/CODE]

I was playing with [URL="

hkdani commented: A willing and inquisitive mind that probes the depths to add knowledge. Gems of wisdom will be gleaned from this source. +6
vedro-compota commented: +++ +3

[QUOTE][CODE]void print_triangle_info(int area(), int perimeter());
void print_square_info(int area(), int perimeter());[/CODE][/QUOTE]
Are 'area' and 'perimeter' functions? If not, why give parentheses after them.the correct form of prototyping will be:
[CODE]void print_triangle_info(int, int);
void print_square_info(int,int);//takes two integers as arguments and return nothing(void)[/CODE]
and then their definitions
[CODE]void print_triangle_info(int area, int perimeter) {//no parentheses after area and perimeter
//Now make use of the area and perimeter to print "triangle info"
}[/CODE]
and then call them from 'main'
[CODE]int main(void) {
//calculate area and perimeter here or create functions to calculate them outside the 'main'

print_triangle_info(area, perimeter);
print_square_info(area, perimeter);
}[/CODE]
edit:
@ WaltP- Wow, that was quick!

minimi commented: Thank you for the heads up! +2

[QUOTE=hufo17][CODE]int ok = 0;
for (x=0;x<=2;x++)
{
y=0;
y++;
if(c[x][y] ==d[x][y])
ok = 1;
}[/CODE][/QUOTE]
It only compares
c[0][1] with d[0][1]
c[1][1] with d[1][1]
c[2][1] with d[2,1] and so on.
If You want to compare each of the elements then, put it in a nested loop
[CODE]for(x=0;x<2;x++)
for(y=0;y<2;y++)
if(c[x][y]==d[x][y])
//rest of the code...[/CODE]

[QUOTE=hugo17][CODE]int a,b;
a = b;//[COLOR="Red"]bad practice[/COLOR][/CODE][/QUOTE]
[QUOTE=hugo17][CODE]char c[2][2];
char d[3][3];
c = d;[/CODE][/QUOTE]Well?Why don't you try that in your compiler? the answer is no. you cannot do that with arrays.
[QUOTE=hugo17][CODE]// or can you compare two arrays to get a true or false statement?
if ( c == d)[/CODE][/QUOTE]
Though the compiler doesn't report any error in this case, you'll not get the intended result from it.Because here, the addresses of arrays c and d are being compared for equality which is never true.
[QUOTE=hugo17][CODE]// or if I want to know if two signs in an array are equal:
if ( c[1][2] == d[1][2])[/CODE][/QUOTE]This is the correct form.
[QUOTE=hugo17]Is it possible to use the equal sign = on arrays like you can use it on variables. If yes how do I write it correctly?[/QUOTE]
Suppose you have an array [CODE]int array[5][/CODE]
then you can assign values to them like this
[CODE]array[0]=1;//1st address assigned to 1
int i;//will be used as offset address
for(i=1;i<5;i++)
array[i]=i+1;//2nd address contains 2, 3rd address contains 3 etc.[/CODE]

Though, the thread has been marked solved, I would like to point few things out. [QUOTE=hkdani]If you don't want to mess with getting rid of the '\n', then just use gets.[/QUOTE]No, never use 'gets()' while taking strings as input([URL="

hkdani commented: Leaves helpful comments giving insights into the intracies of important principles in the programming language. +5

[QUOTE]...that's your homework [/QUOTE]
I'm sorry that I sounded like your professor up there, but my only intention was to help you find the bug, and it was simple so I thought that you were able to find that on your own.
[QUOTE]I'm thinking that your solution was the following for line 9.
[CODE]printf("%d", matrices[Index][i])[/CODE][/QUOTE]
No, it was not.
It was this:
[CODE]printf("%d",matrices[i]);[/CODE]
Because, the pointer "matrices" you're passing to the function "Display" is equivalent to "matrices[index]" for which you dynamically allocated memory in your 'main'
[CODE]matrices [Index] = (int ) malloc( size sizeof(int));[/CODE]
And you only got the first member because 'Index' in your 'Display' function always remains zero.
So you can also do like this:
[CODE]for (Index = 0; Index <= size; Index++)
{
printf("%d", matrices[Index]);
}[/CODE]
And also I can't believe that [B]someone who has done several projects[/B] is still [B]having trouble understanding the concepts of pointers and then applying them[/B]?

[QUOTE=vedro-compota]I don't understand - why compiler allows such code = [/QUOTE]
You can do like this then.
[CODE]#if defined(_WIN32)||defined(_WIN64)

//Windows specific includes and code goes here..

elif defined(linux)

//linux specific includes and code goes here..

endif[/CODE]

Remove this line
[QUOTE][CODE]int mainmenu();[/CODE][/QUOTE]
from both 'main' and 'winmain'.
and add a prototype of the function mainmenu at the beginning .
[CODE]...
int mainmenu(void);

int main()
...[/CODE]

vedro-compota commented: ++ +3

[QUOTE=vedro-compota]but what about point between words - it's feature of objective programming , but original c is functional language , isn't it?
if "isn't" how can it be implemented without objective style? [/QUOTE]
Well, WNDCLASS is a structure defined in 'windows.h' and the contents of a structure are accessed with a dot operator, remember!
See [URL="

vedro-compota commented: +++++ +3

You might want to add a getchar() after that scanf ,
[CODE]...
printf("Enter name, price and pages\n");
fgets(b[i].name, 25, stdin);
scanf("%f %d", &b[i].price, &b[i].pages);
getchar();
}
...[/CODE]
After scanf has read your input ,a '\n'(which was typed just after the number) is still left in the input buffer, so we use that getchar to empty the buffer.
scanf() is a bit complex function to handle, especially when taking input interactively from the user. It'll fail to do the job at hand if it doesn't get what it is expecting.Here in your program, user must enter a string followed by a floating point number followed by an integer.If a user fumbled and mistakenly (or intentionally) entered a floating point number instead of an integer, the program will misbehave.
So I'd suggest you to use fgets even also to read the numbers the from user and later convert them using atoi and atof to their respective formats.

First of all, you're using the if statement in the wrong way(a semicolon before the body)
[QUOTE][CODE]if (t != NULL);
{
printf("%s\n",line);// here you should use "t" instead of "line"

}[/CODE][/QUOTE]

Strtok separates the string in tokens separated by a delimiter string (here " "). Printing the "t" will print the first token at first.
[CODE]fgets (line, sizeof (line), fp);
char t=strtok(line," ");
if (t != NULL)
printf("%s\n",t);[/CODE]
calling strtok for the second time (with NULL as the first argument if you're reading from the same string) will print the second token and so on.If there are no tokens left it will return NULL.
[CODE]fgets (line, sizeof (line), fp);
char
t=strtok(line," ");/in the first call the first argument should not be NULL/
if (t != NULL)
printf("%s\n",t);
t=strtok(NULL," ");
if (t != NULL)
printf("%s\n",t);
t=strtok(NULL," ");
if (t != NULL)
printf("%s\n",t);[/CODE]
So to achieve the output you want you have to do like this:
[CODE]...
if (fp == NULL)
perror ("error opening file");
else {
while(fgets (line, sizeof (line), fp)){
t=strtok(line," ");
printf("\n");
while( t != NULL ) {
printf( "%s\t",t);
t = strtok( NULL, " " );
}
}
}
...[/CODE]

Ancient Dragon commented: good info +17

It's because of this line
[CODE]int a[n];[/CODE]

You cannot declare arrays like that.
Here either 'n' should be initialized prior to declaring array
[CODE]printf("Enter size:");
scanf("%d",&n);
int a[n];[/CODE]

or n should be replaced by some constant value.
like this:
[CODE]

define BUFFER 100

...
int a[BUFFER];
[/CODE]

challarao commented: Thank you +2