Home:ALL Converter>A code that doesn't work on gcc

A code that doesn't work on gcc

Ask Time:2015-04-18T05:56:02         Author:Tolga Şen

Json Formatter

I wrote a calculator program in visual studio. But i need it to run with also DEVC++. But my code doesn't work on gcc compiler. Here is a little part of the code that doesn't work.

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

int main(){

    long double var1 = 0, var2= 0, memory, result;
    char wordInput[50] = { 0 };
    char *endPtr1, *endPtr2;

    printf("Enter an input: ";
    scanf("%[^\n]%*c", wordInput);

    var1 = strtold(wordInput, &endPtr1);
    printf("%.4f", var1);

}

This is the block of code where i get the input and convert it to double and assign to the var1. When i compile it with visual studio it works(it prints the number which is entered) but with devc++ it doesn't (it prints 0.0000). What can i do to fix it?

Author:Tolga Şen,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/29710064/a-code-that-doesnt-work-on-gcc
BLUEPIXY :

try this\n\n#define __USE_MINGW_ANSI_STDIO 1\n#include <stdio.h>\n\n....\n\n printf(\"%.4Lf\", var1);\n",
2015-04-17T22:15:54
yy