Thread: How to edit output in struct and call for the output

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    2

    Unhappy How to edit output in struct and call for the output

    Help plzz

  2. #2
    Registered User claudiu's Avatar
    Join Date
    Feb 2010
    Location
    London, United Kingdom
    Posts
    2,094
    This does not qualify as asking for help. Nobody has the time to go through your code and try to understand what the problem is. You need to be specific about what you need to do, what have you done so far and what you are having problems with

  3. #3
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,613
    You declare home name as a global variable on line 40. You then redefine the variable elsewhere, which, according to the rules of scope, will cause the program to look at the name closest to the working code. The one with no information.

    Delete the global so that you can use the other home name variables, and change your functions so that they return the variables they change. To do that you have to list the struct name before the function name, both in the prototype and definition. Read more here: Cprogramming.com Tutorial: Functions

    There's also no reason to hide small programs in an attachment when you ask things about it:
    Code:
    #include<conio.h>
    #include<stdio.h>
    #include<stdlib.h>
    
    struct home
    {
    	char fullname[50], address[20];
    	int age;
    };
    struct fullinfo
    {
    	struct home name;
    };
    void function(struct home name)
    
    {
    	printf("Enter name:");
    	scanf("%s",&name.fullname);
    	printf("\nEnter address:");
    	scanf("%s",&name.address);
    	printf("\nEnter age:");
    	scanf("%d",&name.age);
    }
    void show(struct fullinfo bin)
    {
    	struct home name;
    
    	printf("\nName:%s %s",bin.name.fullname);
    	printf("\nAddress:%s %s",bin.name.address);
    	printf("Age:%d %d",bin.name.age);
    }
    
    int rec( struct fullinfo bin, struct home name)
    {
      return (strcmp(name.fullname, bin.name.fullname)==0)
      && (strcmp(name.address, bin.name.address)==0)
      && (strcmp(name.age, bin.name.age)==0);
    }
    
    struct home name;
    void show(struct fullinfo bin);
    int rec( struct fullinfo bin, struct home name);
    
    void main()
    {
    	struct home name;
    	struct fullinfo bin;
    	int fin;
    	clrscr();
    
    	function(name);
    	show(bin);
    	printf("\n1. Edit\n2. Delete \n 3. Exit\n");
    	printf("Enter Here:");
    	scanf("%d",&fin);
    	switch(fin)
    	{
    		case 1:
    		{
    			function(name);
    			show(bin);
    			getch();
    		}
    		case 2:
    		{
    			printf("\nFullname:");
    			printf("\nAddress:");
    			printf("\nAge:");
    			exit(0);
    
    		}
    		case 3:
    		{
    			exit(0);
    		}
    	}
    	getch();
    }

  4. #4
    Registered User
    Join Date
    Mar 2010
    Posts
    2
    i cant get what you mean, sorry,

    i just want to ask if anybody can edit my program so that i can get:

    input:
    name: andrew
    address: jones
    age: 24

    show (output);
    ask if want to be edit name/address/age:

    if edit name;
    name: miles
    if edit address;
    address: hideaway
    if age;
    age: 22

    then show final output.>>>>
    \thats all, i keep breaking some of my programs but i just cant do this
    Last edited by andrewkho; 03-16-2010 at 09:43 PM. Reason: add

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    We're not here to do everything for you. And while someone apparently does have time to go through your code and to try to understand the problem -- we're just not here to do all the work for you. Generally the way this works is you explain specifically what you want to do and what you can't seem to do, and we work from there.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help assignment due tomorrow
    By wildiv in forum C Programming
    Replies: 6
    Last Post: 01-27-2010, 08:38 PM
  2. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  3. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM