Vector pointer problem

#include <iostream>
#include <vector>
using namespace std;
main(void){
vector<int> *a;
a->at(0)=0;
printf("%d\n",a->at(0));

}

Something wrong with this code.
It results in segmentation fault.
Could anyone help?
no memory has been allocated to your pointer a. This is how you should initialise a:

vector<int> *a = new vector<int>();

Read up on pointers and dynamic memory if you don't understand what this means. This site is a good place to start

http://www.cplusplus.com/doc/tutorial/pointers/
http://www.cplusplus.com/doc/tutorial/dynamic/

Also I notice that main has no return type here, it should return an int, I'm surprised that this even compiles, which compiler are you using?
Topic archived. No new replies allowed.