c - 总线错误:尝试在方法之间传递字符时返回 10
问题描述
嗨,我是 c 语言的新手,还没有完全理解指针。我正在为我的程序编写一个简单的用户名/密码认证过程,它目前看起来像这样:
void authenticate_process(int cli_sockfd){
/* Authentication Process */
write(cli_sockfd, "USN", 3);
char *username;
username = recv_msg(cli_sockfd);
printf("[DEBUG] Client username is %s.\n", username);
write(cli_sockfd, "PSW", 3);
char *password;
password = recv_msg(cli_sockfd);
printf("[DEBUG] Client Password is %s.\n", password);
//From Here the program breaks
bool approval = authenticate_login(username, password);
printf("%c", approval);
}
bool authenticate_login(char *username, char *password)
{
printf("Made it here");
FILE *file;
char *file_username;
char *file_password;
bool match;
printf("%s", username);
printf("%s", password);
// BLAH BLAH BLAH MORE CODE IN THIS SECTION
return match;
}
我可以在 authenticate_process 方法中获取并打印出客户端的用户名和密码,但是一旦我到达线路,bool approval = authenticate_login(username, password);
我Bus Error: 10
相信这与我如何传递字符有关,但我可能是错的。有人可以解释一下并告诉我如何解决我的问题吗?
解决方案
推荐阅读
- excel - 对象_worksheet的方法范围失败-但当我点击“运行子(F5)”时有效
- python - scrapy(python)中的无效xpath
- python-3.x - 如何使用 python 和 BeautifulSoup 更新 xml 文件
- r - 执行许多模拟以避免for循环
- css - 当我单击选择时,滚动条空间消失并且所有页面内容都向右移动
- git-extensions - Git 扩展:我可以在 Git 扩展中使用本地 .gitconfig 吗?
- linux - CodeIgniter 消息:实时服务器上的“找不到类”
- angular - 在延迟加载的模块中加载小型 Angular 模块
- reactjs - React Material UI + Formik FieldArray Autocomplete 控制值在删除时保持不变
- java - 骆驼端点没有被嘲笑