473,668 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is the problem in this code?

1 New Member
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. struct Node
  4. {
  5.     int data;
  6.     struct Node *add;
  7. };
  8. void insert(struct Node **,int );
  9. void main()
  10. {
  11.     int pos,value;
  12.     struct Node* head=NULL; struct Node *point;
  13.     insert(&head,10);
  14.     insert(&head,20);
  15.     insert(&head,30);
  16.     insert(&head,40);
  17.     insert(&head,50);
  18.     insert(&head,60);
  19.     insert(&head,70);
  20.     insert(&head,80);
  21.     insert(&head,90);
  22.     insert(&head,100);
  23.     printf("Enter the position from the last to be displayed:");
  24.     scanf("%d",&pos);
  25.     point=display_nth(head);
  26.     value=point->data;
  27.     printf("\n%dth value for nth node is %d",pos,value);
  28.     display(head);
  29. }
  30. insert(struct Node** ref_head,int new_data)
  31. {
  32.     struct Node* temp=(struct Node*)malloc(sizeof(struct Node));
  33.     temp->data=new_data;
  34.     temp->add=(*ref_head);
  35.     (*ref_head)=temp;
  36. }
  37.  
31 1 C:\Users\GARIMA \Documents\nth from last.c [Warning] conflicting types for 'insert' [enabled by default]
8 6 C:\Users\GARIMA \Documents\nth from last.c [Note] previous declaration of 'insert' was here
C:\Users\GARIMA \AppData\Local\ Temp\ccqujr3n.o nth from last.c:(.text+0 x116): undefined reference to `display'
C:\Users\GARIMA \Documents\coll ect2.exe [Error] ld returned 1 exit status
Sep 23 '18 #1
1 1179
weaknessforcats
9,208 Recognized Expert Moderator Expert
In the function prototype insert() returns void.

In the function definition insert() return int.

oops.

When the return type is not specified, it defaults to int.

BTW: main() returns int. Not void. main() is the only function that returns int and you don't need a return statement.
Sep 23 '18 #2

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

Similar topics

2
1351
by: PDXWilliam | last post by:
Hello, Please forgive if this is off-topic ... and I'd welcome if someone pointed me elsewhere to find this info. I'm programmatically retrieving data from a website and am unable to figure out what I should be sending to grab this data. Please bear with me for a 15 second demo that explains it more clearly ... At this website:
9
3315
by: Mike L | last post by:
I tried a sample of code in MSDN magazine, but now I'm stuck. What code has the best performance to populate a Data Grid with a SP? Below is the code I have, which might be completing the wrong way to populate a data grid. I like using code and not the server explorer. (I replaced the sa password for this post.) private void frmDealerSearch_Load(object sender, System.EventArgs e) { string sConnString = "Data
0
1124
by: VM | last post by:
I have a pretty big application made in C but I only want to view the code that's being executed when a button in a toolbar is clicked. Since I didn't write the program, is there an easy way to find what code is being executed in a certain event? Thanks.
1
1741
by: Mateusz Rajca | last post by:
Hello, What code should I write to hide the taskbar? Mateusz
2
1677
by: mistral | last post by:
what code encoded in this snippet? <script language=JavaScript>function dc(x){var...
1
1296
by: bb nicole | last post by:
What coding should i have if i want to display all the latest job(according to date) which call out from database. For example, all today will display in the website... What code should i have to display it?? Thanks...:)
0
1138
by: sheenaa | last post by:
Hi Everyone, I m using ASP.NET 2005 with C# and SQL SERVER 2005. I m using stored procedure and sql datasource control to retrieve the data. I want to use the trigger alongwith storedprocedure. I have created the following trigger on emp_table.
1
1353
by: Ninoy | last post by:
I am doing a program in vb 6.0 what code will i use in order to separate date and time in listview and move the time in the next column and also how can i do a loop with it so that the last date and time will be in the last column
2
10090
by: Joseph VH | last post by:
hello What code do I need to use on my Form to add background music and where do I put It. I think I have to put it in Joseph
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8797
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8583
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8656
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5681
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4205
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.