增加学生人数

时间:2019-01-01 20:16:14

标签: c

试图制作一个可以存储学生信息的程序,到目前为止,当用户选择应存储的学生数量时,我遇到了一个问题。也许我错过了一些东西,但我找不到它,当我而不是在这种情况下使用n(要存储的学生数)为10时,它可以正常工作,然后10个学生被注册,但是现在我想更改此设置,因此用户应该选择要添加的学生人数。

在用户选择了学生数量之后,它跳过了“存储信息”部分,然后跳到结尾,所以我想这就是问题所在。

let url = URLs.addPlaceBooking
let headers: HTTPHeaders = ["Content-type": "application/json"]
let paramters : [String : Any ] = [
    "BRANCH_ID" : "23",
    "PACKAGE_ID": "10",
    "ARRIVE_TIME_ID": "12",
    "ARRIVE_DATE" : "12/2/2014",
    "IS_TABLE" : true,
    "IS_TICKET" : false ,
    "NOTE": "",
    "persons" : [
        "ID": "1",
        "FIRST_NAME":"Ali",
        "LAST_NAME":"Ahmed",
        "GENDER":"Male",
        "MOBILE":"0111281456",
        "EMAIL":"mz_@.fgj",
        "FACEBOOK_URL":"www.google.com",
        "IS_MEMBER": true,
        "IS_BOOKER": true],
        "addons": []
    ]
]

Alamofire.request(url, method: .post , parameters:  paramters, encoding: URLEncoding.default , headers: headers).responseJSON { respons  in
    switch respons.result {
        case .success(let value ): print(value)
        case .failure(let error): print(error)
    }
}

1 个答案:

答案 0 :(得分:0)

struct student
{
  char name[50], number[13], gender[6], program[50], age[3], email[100];
  int roll;
} s[10];

int main(){

int i, n;

printf("Enter how many students to add:\n");
// the problem was here
scanf("%d", &n);

// storing information
i = 0;
for (i; i < n; ++i)
{
    s[i].roll = i + 1;

    printf("\nFor roll number%d\n", s[i].roll);   //number of the student

    printf("Enter name: \n");
    scanf("%s", s[i].name);

    printf("Enter personal number (yyyymmdd-xxxx):\n");
    scanf("%s", &s[i].number);

    printf("Enter gender (male or female):\n");
    scanf("%s", &s[i].gender);

    printf("Enter program of student: \n");
    scanf("%s", &s[i].program);

    printf("Enter age of student: \n");
    scanf("%s", &s[i].age);

    printf("Enter email of student: \n");
    scanf("%s", &s[i].email);

    printf("\n");
}

printf("Displaying Information:\n");}

%s格式用于字符串,%d格式用于整数