programming error help

June 25, 2011 at 03:34:49
Specs: Windows 7, AMD Athlon 7750/ 2GB
i have written this code of C++ for turbo ++ to create a linklist inserting node at beginning...but the compiler is giving one error showing that "declaration syntax error in function main". But i m unable to to find the error ...please help me in this..


struct node{
int data;
node *next;

int main()
int info;
int counter=0;
node *head=NULL;
node *ptr;

// function to insert a node at the begining
void InsAtBeg (int value)
nod=new node;

// inputting data value in the nodes;
cout<<"\n enter the "<<(counter+1)<<" value";
counter ++;

// outputting the stored data values in the nodes
cout<<"\n data stored is ";
cout<<ptr->data<<" ";
return 0;

See More: programming error help

Report •

June 25, 2011 at 05:19:10
You can't define a function (InsAtBeg) within another function (main).

Report •

June 26, 2011 at 11:25:51
can u correct it to show me how to use a function...

Report •

June 27, 2011 at 00:06:06
There's really not enough information here to see what you're trying to do. But it's easy; just define your functions before you define main() and then call the functions within main().

This is basic stuff that can be found in any C++ text. Work your way through a good book; that's the best way to learn if you aren't taking formal classes. If you are taking classes, discuss it with your tutor.

Report •
Related Solutions

Ask Question