1
显示“Quel est ce mot?”后程序崩溃:
我该怎么办,我该如何解决这个问题?
期待您的意见:)
感谢您的帮助!C - Prog crash exec
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wjean-ma <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/08/03 03:07:53 by wjean-ma #+# #+# */
/* Updated: 2015/08/08 21:43:49 by wjean-ma ### ########.fr */
/* */
/* ************************************************************************** */
#include "include/libft.h"
char *ft_putword(char **client, char *str)
{
int i;
i = 0;
while (str[i])
{
if ((*client)[i] != str[i])
(*client)[i] = '*';
else
(*client)[i] = str[i];
i++;
}
return (*client);
}
int main(void)
{
char *to_find;
char *client;
int size;
int buffer;
to_find = "Violet";
size = ft_strlen(to_find) + 1;
if ((client = (char *)malloc(sizeof(char) * (size))) == NULL)
return (-1);
client = "******";
while (ft_strcmp(client, to_find) != 0)
{
ft_putstr("Quel est ce mot: ");
ft_putstr(ft_putword(&client, to_find));
ft_putstr("\n> ");
scanf("%s", client);
while ((buffer = getchar()) != '\n')
;
ft_putstr(ft_putword(&client, to_find));
ft_putchar('\n');
}
ft_putstr("Done\n");
free(client);
return (0);
}
/* ----------------------------------------- ------------------------ */
如何找到:使用调试器! – Amit
使用'gdb'调试器 –
这将试图修改RO内存:(调试器?绝对! –