程序开始不起作用

时间:2015-04-16 18:03:10

标签: c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*username/password/id storage*/
struct Profile
{
    char username[50];
    char password[10];
    char id;
};
struct Profile profile1; /*User Profile */


main(){
    char firstname[79];
    char answer1[4];
    char y[4] = "Yes";
    char username[50];


    printf("   Welcome to Iceburg\n   Working for you\n\n\n\n");
    printf("Is this your first time using our program?(Yes/No)\n");
    scanf("%d", &answer1);
    if (answer1 == y){
        goto start;
    }
    else{
        goto end;
    }

start:
    /*Beginning of program*/
    printf("   Welcome to Iceburg\n   Working for you\n\n\n\n");
    printf("Please enter your first name\n");
    scanf("%s", &firstname);
    system("cls");
    printf("Hello %s,\nWelcome to Iceburg\n\n", firstname);
    /*Collecting data for username/password*/
    printf("First, we need some other data.\n");
    printf("Select a username.(one word with no special characters)\n");
    scanf("%s", &username);
    printf("Thank you!\n");

end:
    return(0);
}

我需要有关程序的帮助,直到“开始:”。自方案以来 检查没有错误但不会运行if else语句我没有 知道还有什么地方要转。如果我能得到一些帮助。我也 需要知道我需要做什么才能创建用户名/密码 登录用户名和密码保存在此处 来源或替代来源。

1 个答案:

答案 0 :(得分:0)

if (answer1 == y){

应该是

 if(strcmp(answer1, y) == 0){

正如其他人所说的那样不要使用goto。使用while循环