Struct function not returning properly

Ok, this code is too long but the problem is the main function is not getting the return value of my function. The function returns a struct btw.

Calling part
 
  placeword(variable);


Function part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
scrabble placeword(scrabble variable){
	int k, j, choice, choice2, r, c, m = 0, length;
	char word[7];	
	printf("----------What do you want to do?----------\n");
	printf("|| [1] - Place a word                    ||\n");
	printf("|| [2] - Can't find a word? Go Back      ||\n");
	printf("-------------------------------------------\n");
	do{
		scanf("%d", &choice);
		switch(choice){
				case 1: printf("Enter your word:\n");
						scanf("%s", word);
						length = strlen(word);
						for(k=0;k<length;k++){
							if(word[k]>=97 && word[k]<=122){	
								word[k] = word[k] - 32;
							}							
						}
						if(length<3){
							printf("Your word is too short!\n");
							break;
						}					
						for(k=1;k<=length;k++){
							for(j=1;j<=7;j++){
								if(word[k]==variable.players[variable.p].tiles[j]){
									m = 1;
									break;													
								}
							}
							if(m==0){
								printf("You don't have the letter %c\n", word[k]);
								break;
							}
						}
						if(m==0){
							break;
						}
						m = 0;
						printf("Pick the row and then the column to which the word is to be placed.\n");
						scanf("%d%d", &r, &c);	
						while(r<0 || r>10 || c<0 || c>10){
							printf("Invalid Input!");
							scanf("%d", &r);
							scanf("%d", &c);
						}
						printf("-------Which way will you put it?-------\n");
						printf("|| [1] - Downward                     ||\n");
						printf("|| [2] - Forward                      ||\n");
						printf("|| [3] - Just kidding. It doesn't fit.||\n");
						printf("----------------------------------------\n");
						do{
							scanf("%d", &choice2);
							switch(choice2){
								case 1: for(j=0;j<length;j++){
											if(variable.board[(r*2)+2+(2*j)][c+2] != 32){
												if(variable.board[(r*2)+2+(2*j)][c+2] != word[j]){
													m = 1;
													printf("Your word does not fit the board!\n");
													break;
												}
											}								
										}
										if(m==0){
											for(j=0;j<length;j++){
												variable.board[(r*2)+2+(2*j)][c+2] = word[j];
												
											}
										
											for(k=0;k<length;k++){
												for(j=1;j<=7;j++){													
													if(word[k]==variable.players[variable.p].tiles[j]){
														m = 1;													
														variable.players[variable.p].tiles[j] = 0;	
														break;													
													}
												}
												if(m==0){
													break;
												}
											}													
										}
										
										return variable;
										break;
								case 2: for(j=0;j<length;j++){
											if(variable.board[(r*2)+2][c+2+j] != 32){
												if(variable.board[(r*2)+2][c+2+j] != word[j]){
													m = 1;
													printf("Your word doesn't not fit the board!\n");
													break;
												}
											}								
										}
										if(m==0){
											for(j=0;j<length;j++){
												variable.board[(r*2)+2+(2*j)][c+2+j] = word[j+1];
											}
											for(j=1;j<length;j++){
												if(variable.players[variable.p].tiles[j] == word[j]){
													variable.players[variable.p].tiles[j] = 0;
												}												
											}
										}
										return variable;	
										break;
								case 3: 
										break;
								default: printf("\nInvalid Input!\n");
								}
						}while(choice2!=2 && choice2!=1 && choice2!=3);
						break;
				case 2: variable.m = 1;	
						return variable;
						break;
				default: printf("\nInvalid Input!\n");
			}
	}while(choice!=2);	
}



The returning parts are in line 84, 104, and 114.
Last edited on
It looks you are not assigning the returned value where you are calling.

1
2
scrabble res;
res = password(variable);
Topic archived. No new replies allowed.