Thread: uexecutable program

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    34

    uexecutable program

    Code:
    #include<stdio.h>
    main()
    {
    struct employee
    {
    chat name[20];
    float salary;
    }x[2];
    int i;
    for(i=0;i<2;i++)
    {
    puts("enter name");
    gets(x[i].name);
    puts("enter salary");
    scanf("&#37;f",&x[i].salary);
    }
    for(i=0;i<2;i++)
    {
    printf("%s\n%f",x[i].name,x[i].salary);
    }
    getch();
    }
    the program takes name and salary
    then it is showing the following error
    Code:
    scanf : floating point formats not linked
    Abnormal program termination
    plz help
    thank you..
    Last edited by shuaib.akram; 08-21-2007 at 11:22 PM.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Try
    Code:
      scanf("&#37;f", &x[i].salary);
    or just
    Code:
      scanf("%f", x[i]->salary);

  3. #3
    Registered User
    Join Date
    Aug 2007
    Posts
    34
    i tried by &x[i].salary
    just a typing mistake in above program
    i did not get that

  4. #4
    Registered User
    Join Date
    Aug 2007
    Posts
    34

    unexecutable program

    Code:
    #include<stdio.h>
    main()
    {
    struct employee
    {
    chat name[20];
    float salary;
    }x[2];
    int i;
    for(i=0;i<2;i++)
    {
    puts("enter name");
    gets(x[i].name);
    puts("enter salary");
    scanf("%f",&x[i].salary);
    }
    for(i=0;i<2;i++)
    {
    printf("%s\n%f",x[i].name,x[i].salary);
    }
    getch();
    }
    the program takes name and salary
    then it is showing the following error


    scanf : floating point formats not linked
    Abnormal program termination
    plz help
    thank you..

  5. #5
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    You should edit your code in your original post instead of starting another thread - and by the way, it's "char", not "chat".

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Threads merged.

    > scanf : floating point formats not linked
    1. This tells me your compiler is very old. Unless your operating system really is DOS (and not a nice window with a c:\> prompt inside say XP), then you should consider a compiler which is more matched to your OS.
    2. This is such a common problem that simply pasting the error message into a search engine gives lots of results.
    http://clusty.com/search?query=scanf...Mozilla-search

    > gets(x[i].name);
    Read the FAQ for why gets() is a really bad function to use.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    835
    Quote Originally Posted by robatino View Post
    Try
    Code:
      scanf("&#37;f", &x[i].salary);
    or just
    Code:
      scanf("%f", x[i]->salary);
    My second expression is wrong - disregard it. You need the address of x[i].salary - the first one is, the second isn't.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Issue with program that's calling a function and has a loop
    By tigerfansince84 in forum C++ Programming
    Replies: 9
    Last Post: 11-12-2008, 01:38 PM
  2. Need help with a program, theres something in it for you
    By engstudent363 in forum C Programming
    Replies: 1
    Last Post: 02-29-2008, 01:41 PM
  3. Replies: 4
    Last Post: 02-21-2008, 10:39 AM
  4. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM