473,396 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

plz tell why is the reason of this error :

1
#include<stdio.h>
#include<ctype.h>

typedef struct node
{
int value;
struct node *next;
struct node *prev;
}mynode ;
void add_node(struct node **head , int value);
void print_list(char *listName , struct node *head );
void getTheMiddle(mynode *head);


// The main function..
int main()
{
mynode *head ;
head = (struct node *)NULL;
add_node(&head, 1);
add_node(&head,10);
add_node(&head,9);
add_node(&head,-99);
add_node(&head,0);
add_node(&head,5);
add_node(&head,19);

print_list(" myList " , head);
getTheMiddle(head);
return 0 ;
}

//This function uses one slow and one fast
// pointer to get to the middle of the LL.
// The slow pointer is advanced only by one node
// and the fast pointer is advanced by two nodes!
void getTheMiddle(mynode *head)
{
mynode *p = head;
mynode *q = head;
if(q!=NULL)
{
while((q->next)!=NULL && (q->next->next)!=NULL)
{
p=(p!=(mynode *)NULL?p->next:(mynode *)NULL);
q=(q!=(mynode *)NULL?q->next:(mynode *)NULL);
q=(q!=(mynode *)NULL?q->next:(mynode *)NULL);
}
printf("The middle element is [%d]",p->value);
}
}
// Function to add a node
void add_node(struct node **head, int value)
{
mynode *temp, *cur;
temp = (mynode *)malloc(sizeof(mynode));
temp->next=NULL;
temp->prev=NULL;
if(*head == NULL)
{
*head=temp;
temp->value=value;
}
else
{
for(cur=*head;cur->next!=NULL;cur=cur->next);
cur->next=temp;
temp->prev=cur;
temp->value=value;
}
}
// Function to print the linked list...
void print_list(char *listName, struct node *head)
{
mynode *temp;
printf("\n[%s] -> ", listName);
for(temp=head;temp!=NULL;temp=temp->next)
{
printf("[%d]->",temp->value);
}
printf("NULL\n");
}

error: expected ‘)’ before ‘(’ token
error: expected ‘)’ before ‘*’ token
Dec 17 '11 #1
1 1218
weaknessforcats
9,208 Expert Mod 8TB
Beats me. There's no error in the code you posted according to Visual Studio.NET 2008.
Dec 17 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Hai Nguyen | last post by:
Would anybody please tell me what is this error and what i should do I have 5 files: page1.aspx,page1.aspx.cs; page2.aspx.page2.aspx.cs and page3.cs both page1.aspx.cs and page2.aspx.cs...
2
by: Varun | last post by:
Hello Despite all the advise i have recieved from everyone on this group i still cannot fix this error. I am fast approachin my deadline so i need to fix this asap :o I get the error whenever i...
1
by: Dan | last post by:
I can't figure out this error message. Could someone please help. I have a text file in Notepad with the following 4 fields (Cont, Code, List, and Numb)all of which are single tab delimited, and a...
2
by: Seth Broomer | last post by:
Can someone please tell me what might be causeing this error. I get it every once in a while. I just noticed this also...where it says c:\sethbacup\d... that is where i do my build. But then i...
6
by: ~Maheshkumar.R | last post by:
The error i'm getting is as: > Server Error in '/' Application. > -------------------------------------------------------------------------- -- > String or binary data would be truncated. The...
0
by: Brad Wood | last post by:
Running a web service on 1.1. Even though I don't recieve any errors in the output of the service, I see a ThreadAbortException in the ide output window when it's debugging, "Thread was being...
22
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of...
8
by: prileep | last post by:
Hi, Dim cn As ADODB.Connection Dim rs As New ADODB.Recordset Dim strSQL As String Set cn = New ADODB.Connection With cn .Provider = "Microsoft.Jet.OLEDB.4.0" .Open...
3
by: eighthman11 | last post by:
Hi everyone: We received a error message "Log File to Database is Full. Backup the transaction log to free up space." I have a Access 2000 application that calls a Stored Procedure that...
3
by: Renzr | last post by:
I have a C++ package which works very well in the 32-bit Linux-like OS. However, it will lead to a "*** glibc detected *** ./ex2: munmap_chunk(): invalid pointer" in 64-bit (Fedora 7-64), when it...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.