C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 26th, 2015, 06:02 AM
ranjeet ranjeet is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2015
Posts: 1 ranjeet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 50 sec
Reputation Power: 0
Syntax errors - Getting Error While Passing Structure as a function Argument in C ?

Hello,

I was trying to pass structure as a function argument in c programming language, and for this I created the Object of the Structure and pass it as an argument to the function. But I am not getting correct output as the c program is showing some error. I hope this is one of the highly specific c programming questions and answers forum where I can get solutions to my query. Can anyone help me to resolve this issue?
Code:
#include<stdio.h> #include<conio.h> struct anp//Name of the structure { int rlno; //Structure elements char name[15]; }p;//structure variable void print(struct anp *); void main() { clrscr(); printf("Enter the rlno and name\n"); scanf("%d%s",&p.rlno,p.name); print(&p);//calling the function print and &p is structure  Argument getch(); } void print(struct anp q) { printf("Entered ROLLNO =%d Entered Name= %s",q->rlno,q->name); }

Reply With Quote
  #2  
Old August 11th, 2015, 05:15 PM
greadey greadey is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2015
Posts: 1 greadey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 14 sec
Reputation Power: 0
Hi there,

Funnily enough I am trying to do a very similar thing except pass an array of structs to a function. Unfortunately (read FORTUNATELY) for you I am (although a fairly basic C coder) rather inclined to let you know that if you fix the very simple errors in your code, you might get it to work yourself. It does work on my machine after applying my own advice :-)
Although I do not know which compiler you are using I suspect that it is actually telling you what might be wrong.
Good luck,

greadey

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Syntax errors - Getting Error While Passing Structure as a function Argument in C ?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap