I am trying to pass in a dynamic array to a function, add two values then print them in main. My current compile only prints "here". Where did I go wrong?
#include <iostream>
using namespace std;
void enqueue(int v1, int v2,char *q,int &size); //push value to back of
queue
void dequeue(); //delete value @ q[0]
int main(){
int size = 0;
char* q = new char[size];
enqueue(1,2,q,size);
cout << q[2] << endl;
for (int i=0; i<size; i++){
cout <<q[i];
}
}
void enqueue(int v1,int v2, char *q,int &size){
cout << "here" << endl;
size++;
q[size]=v1;
size++;
q[size]=v2;
}
enter code here