floating pointer format not linked

i try to do stuct using pointer tat include float.
how to fix the error of "floating pointer format not linked"?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  #include<stdio.h>
#include<conio.h>
void main()
{
	struct student
	{char name[30];
	int mark;
	float gpa;
	}


st[10], *p;
int n,q=0;
clrscr();
printf("\nEnter number of students: ");
scanf("%d",&n);
printf("\nEnter the data:");

for(p=st; p<st+n; p++)
{
q++;
printf("\nEnter student name: ");
scanf("%s",&p->name);
printf("\nEnter mark: ");
scanf("%d",&p->mark);
printf("\nEnter gpa: ");
scanf("%f",&p->gpa);
}

p=st;
printf("\nEntered Data: ");
q=0;
while(p<st+n)
	{
	q++;
	printf("\nStudent name: %s",p->name);
	printf("\nFinal mark: %d",p->mark);
	printf("\nG.P.A.: %.2f",p->gpa);
	p++;
	}
		getch();
}
IDK what line the error occured on yours, my compiler doesn't report "floating pointer format not linked"

when passing a char array into printf, you don't need '&' operator, name is a pointer itself

btw, pls fix you indentation, it will make your code structured and clear

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <conio.h>

int main()
{
    struct student
    {
        char name[30];
        int mark;
        float gpa;
    } st[10], *p;

    int n; /*, q = 0; */ // you're not really using q variable

    clrscr();

    printf( "\nEnter number of students: " );
    scanf( "%d", &n );

    printf( "\nEnter the data:" );

    for( p = st; p < st + n; ++p )
    {
        //q++;
        printf( "\nEnter student name: " );
        scanf( "%s", p->name );
        printf( "\nEnter mark: " );
        scanf( "%d", &p->mark );
        printf( "\nEnter gpa: " );
        scanf( "%f", &p->gpa );
    }

    p = st;
    printf( "\nEntered Data: " );
    //q=0;
    while( p < st + n )
    {
        //q++;
        printf( "\nStudent name: %s", p->name );
        printf( "\nFinal mark: %d", p->mark );
        printf( "\nG.P.A.: %.2f", p->gpa );
        ++p;
    }
    getch();
}
Last edited on
Topic archived. No new replies allowed.