P
Profetas
I know what is causing the problem, but I couldn't
find out why.
#define newline "\n"
#define question_mark "\?"
#define single_quotas "\'"
#define double_quotas "\""
#define form_feed "\f"
#define horizontal_tab "\t"
#define vertical_tab "\v"
#define backslash "\\"
#include <stdio.h>
main(){
int var;
printf("Type a number:");
scanf("%d",&var);
printf("The number is ");
printf("%d",var);
printf(newline);
char *var2;
printf("Type a string:");
int bytes_read=0;
int nbytes = 100;
var2 = (char *) malloc (nbytes + 1);
bytes_read = getline (&var2, &nbytes, stdin);
if(bytes_read == -1)
{puts ("ERROR!: invalid input");}
printf("The string is ");
printf("%s",var2);
printf(newline);
}
find out why.
#define newline "\n"
#define question_mark "\?"
#define single_quotas "\'"
#define double_quotas "\""
#define form_feed "\f"
#define horizontal_tab "\t"
#define vertical_tab "\v"
#define backslash "\\"
#include <stdio.h>
main(){
int var;
printf("Type a number:");
scanf("%d",&var);
printf("The number is ");
printf("%d",var);
printf(newline);
char *var2;
printf("Type a string:");
int bytes_read=0;
int nbytes = 100;
var2 = (char *) malloc (nbytes + 1);
bytes_read = getline (&var2, &nbytes, stdin);
if(bytes_read == -1)
{puts ("ERROR!: invalid input");}
printf("The string is ");
printf("%s",var2);
printf(newline);
}