Funtions not working together

I have 2 functions that I cant seem to get to work together. One sets up an aray of numbers and shuffles the numbers. The other one pulls the numbers a number in order of index each time its called. (basically the first time its called it returns the number in index 0. The second time its called it returns the number in index 1 and so on) I (with some help) got the functions to work when written as one function, however the assignment requires that they work as two separate functions, though they can work together, if that makes sense. Anyway the errors I keep getting are :

error C2109: subscript requires array or pointer type IntelliSense: expression must be a pointer to a complete object type

I think that I have a problem with my return values but I cant seem to be able to figure it out.

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
 #include "stdafx.h"
#include <iostream>
#include <cstdlib>       
#include <ctime>          
#include"getcard.h"
#include"deck.h"

using std::cout; using std::endl;
using std::cin;



int deck();
int getcard();

int deck()     //sets up the deck and shuffles it
{
	int deck[52]={2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,
		10,10,10,10,11,11,11,11};
int x,p,temp;

srand(time(NULL));			// seed for random function

for (p=0; p<520; p++){
	int k = rand()%52;
	int l = rand()%52;
		temp=deck[k];
		deck[k]=deck[l];
		deck[l]=temp;
	return(deck[x]);
}
}

int getCardCalled=-1;       //deal function, incriments every time a card is drawn
int getcard() {
	++getCardCalled;
	
	return deck[getCardCalled];
}


int main()	//main is for testing to see if the two functions work together			
{
cout<<endl;cout<<endl;
int i;
	
for (i=0; i<52; i++){        //to print out shuffled deck
    cout<<deck[i]<<" "; 
}
cout<<endl;cout<<endl;
cout<<getcard();		//to see if it increments correctly
cout<<endl;
cout<<getcard();
cout<<endl;
cout<<getcard();
cout<<endl;
cout<<getcard();
cout<<endl;cout<<endl;

cout<<" Blackjack"<<endl;
	cout<<endl;cout<<endl;
}
You should fix your indentation first ;)
I'm sorry. My instructor hasn't given us any guidance on that. Do have a style that you recommend?
Just be consistent with your indentation. That's the most important thing.

As for your error, is there any particular reason you're not telling us which line number the error occurs on? Is this supposed to be some kind of puzzle for us?

In any case, in your getcard() function, at line 38, there's no variable in scope called deck so the compiler will be seeing it as a function name (defined on line 13).

Ditto in main, at line 48.
Topic archived. No new replies allowed.