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內存:(調試器?絕對! –