[cpp] sumthing wrong with comparing
Code:
// Namu_Darbas_01.cpp
//
#include "stdafx.h" //MS STUDIO 2005
#include "stdio.h"
#include "math.h"
int main()
{
printf("FOR AR WHILE to be used ('for' or 'while')?\n");
char choosed[10];
scanf("%s",&choosed);
printf("INPUT: %s \n",choosed);
if (choosed == "for")
{
printf("BUS NAUDOJAMASI FOR\n");
double x,y;
for (x=0.1;x<=1.5;x+=0.07)
{
y=sin(x);
printf("NUMB: %f \n",y);
}
}
else
{
printf("BUS NAUDOJAMASI WHILE\n");
double x,y;
x=0.1;
while (x<=1.5)
{
y=sin(x);
printf("NUMB: %f \n",y);
x+=0.07;
}
}
int temp1;
scanf("temp1");
getchar();
return 0;
}
I had started to program on C and encountered quite dumb logical error and I don't see where's the problem.
Why the hell in the
Code:
if (choosed == "for")
bool is 0? the expression is true, isn't it??
previously I have tried to use INT for asking question what method will be used (1 for FOR and 2 for WHILE) and it was ok on comparing.