如何通过将用户的主题作为另一种C语言的结构成员来分配结构成员中的节

时间:2019-12-30 09:25:47

标签: c structure

/*Take value and store in structure member, compare with constant
  do batch allotment in it.*/

#include <stdio.h>
#include <conio.h>

void main()
{
    struct student{
        float mrk;
        char sub[10];
        char sec[10];
    } st[2];
    int i;
    float *p=&st[i].mrk;
    clrscr();
    for (i=0; i<2; i++)
    {
        printf("Enter 12th mrks: ");
        scanf("%f", &st[i].mrk);
        fflush(stdin);
        printf("Enter subject: ");
        gets(st[i].sub);
    }
    for (i=0; i<2; i++)
    {
        if (st[i].sub=="cse")
            strcpy(st[i].sec,"A");   //st[i].sec="A";
        else if (st[i].sub=="me")
            strcpy(st[i].sec,"B");   //st[i].sec="B";
        else
            strcpy(st[i].sec,NULL);  //st[i].sec=NULL;
    }
    printf("\n numbers \t sub \tsec \n");
    printf("-------------------------------------\n");
    for (i=0; i<2; i++)
    {
        printf("%f\t%s\t%s\n",st[i].mrk,st[i].sub,st[i].sec);
    }
    getch();
}

你好这是代码。请帮忙。我无法获得根据用户的主题分配部分的输出。它没有打印任何内容,并且我正在开发的turbo c7编译器没有错误。

0 个答案:

没有答案