SomeBody Know This Problem

help me to find my error here
we i run this program hmm....
the output is two the aquarius
and pieces and sometimes the march cannot read !

#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf

char w[50];
int t;


void main()
{
clrscr();
p("Enter Month:");
gets(w);
p("Enter Day:");
s("%d",&t);
if((w=="january") || (w=="January") || (w=="jan") || (w=="Jan") || (t>=20 && t<=31))
   {p("Your Are Aquarius");}
else if((w>="February") || (w=="february") || (w>="Feb") || (w=="feb") && (t>=1 || t<=18))
   {p("Your Are Aquarius");}
if((w=="February") || (w=="february") || (w=="Feb") || (w=="feb") && (t>=19 && t<=29))
   {p("Your Are Pieces");}
else if((w>="March") || (w=="march") || (w>="Mar") || (w=="mar") && (t>=1 && t<=19))
   {p("Your Are Pieces");}
getch();

}
jephthah commented: this code is just so full of horribleness, i cant let it go. i realize you're a noob, but this has about every bad example you could possibly stick in. and you didnt even use code tags. -1

Recommended Answers

All 16 Replies

oh. my. god.

get rid of that "gets" statement right now. replace it with "fgets"

and change your "void main" to "int main(void)" while youre at it, since that is sloppy practice.

but seriously, "gets" is some effed up shiite. never ever use it.

ever.

and, really, "conio.h"? "clrscr()"?? getch()???

where the hell are you getting your instruction from? your teacher needs to be hit upside the head with a board.

oh, let me guess: India. right?

.

commented: J, c'mon. If you're going to tell sombody not to use shit for code, tell them WHY!!! Is there some reason they should just believe you? Think, man! -2

See, I didn't even have to say anything. :D I think I had started to but got distracted. Don't forget the conio.h too, nice and non-standard.

commented: heh. my edit and your post passed each other like ships in the night :) +6

Dear Bantex

I'm sorry, i was overly harsh and mean to a beginner. it's late where i am, and i should go to sleep.

but seriously, your teacher needs a board upside their head. and anyone involved in your educational system. they are failing you. look up what im talking about, if you don't believe me. it's commonly known in any technically proficient arena.

i mean it. whoever is teaching you these habits is an idiot. get away from these bad habits now, or you will be doomed to a career in tech support call centers.

oh. my. god.

get rid of that "gets" statement right now. replace it with "fgets"

and change your "void main" to "int main(void)" while youre at it, since that is sloppy practice.

but seriously, "gets" is some effed up shiite. never ever use it.

ever.

and, really, "conio.h"? "clrscr()"?? getch()???

where the hell are you getting your instruction from? your teacher needs to be hit upside the head with a board.

oh, let me guess: India. right?

.

In phillipines!

bantex, even though jephthah comes tromping into your thread being condescending and belligerent, spouting derisions and opinions with no backing explanations, he is correct. He feels you are just supposed to trust him. Allow me to add the small bits of information he neglected to tell you:

get rid of that "gets" statement right now. replace it with "fgets"

Yes, gets() is a very ill-behaved function. Here's why.

and change your "void main" to "int main(void)" while youre at it, since that is sloppy practice.

It's not sloppy. It's wrong. See this.

and, really, "conio.h"? "clrscr()"?? getch()???

conio.h is not standard C. It is an extension to a select few compilers and when you come to rely on it, you will find all your code broken when you change to a different compiler. Best to stick with standard C headers and functions.

your teacher needs to be hit upside the head with a board.

I also agree with him here, too. Your instructor needs to get out of the 1980's and teach real C -- Standard C, and stop using a 25-year-old compiler because it's familiar.

commented: i'll trade give you my green for your red. +6

though jephthah comes tromping into your thread being condescending and belligerent, spouting derisions and opinions with no backing explanations, he is correct. He feels you are just supposed to trust him

because i've explained the "why's" at length a number of times previously. i've grown tired of doing it.

usually i just ignore it now, mostly, until i see a triple-header like this one.

it's nice that you still have patience. srsly, you'll probably live longer than me.

because i've explained the "why's" at length a number of times previously. i've grown tired of doing it.

If you stop yelling about it and make a descent thread with something like "The 10 things in C(++) you think are right, but aren't" and explain all the void main(), gets, clrscr, and other horrible things in detail, I'll consider making it a sticky, and you can just link to it.

it's nice that you still have patience.

WaltP has his ups and downs :D

commented: There should be a "Turbo C: What your prof won't tell you" thread too. Seriously... +2

If you stop yelling about it and make a descent thread with something like "The 10 things in C(++) you think are right, but aren't" and explain all the void main(), gets, clrscr, and other horrible things in detail, I'll consider making it a sticky, and you can just link to it.

You mean like I always do :icon_wink:


WaltP has his ups and downs :D

:icon_razz: plbbbbbb

You mean like I always do :icon_wink:

I was talking about a thread with all the most common "newbie-errors". But if you think that you have any posts lying around somewhere that'll do the job, be my guest to sticky it :icon_cool:

I hate bringing up old threads but I was thinking about this but did not have the courage of asking a MOD but this seems like a good opportunity. So, can i make a list of Common malpractices of C?

So, can i make a list of Common malpractices of C?

Sure. There's currently a discussion in Area 51 (the Mod/Sponsor forum) about this very subject, but if you'll send me your idea's I'll post them there. That way we can collect the best of everything and start 1 thread.

ugh, i just noticed something else really bad in this code:

#define s scanf
#define p printf

//...

p("Enter Day:");
s("%d",&t);

good lord, what's that about?

Thx Guys :(

oh. my. god.

get rid of that "gets" statement right now. replace it with "fgets"

and change your "void main" to "int main(void)" while youre at it, since that is sloppy practice.

but seriously, "gets" is some effed up shiite. never ever use it.

ever.

and, really, "conio.h"? "clrscr()"?? getch()???

where the hell are you getting your instruction from? your teacher needs to be hit upside the head with a board.

oh, let me guess: India. right?

.

i use the "conio.h" library and its functions because in visual C++ the program just executes and the cmd closes after that, so it helps me in seeing my execution

commented: Did you read the rest of the thread?? -1

Then get rid of conio.h and use getchar() instead. It's standard.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.