more problems with my C program

I've run into 2 problems now, the first problem is probably a simple one it is in reguards to the argv[] pointer
I have an if statement as follows:

if(argv[1] == "-l")
{
printf("output:");
printf("TASK-NO\tDATE\tTIME\tTASK DESCRIPTION");
return(0);
}

but when I compile the program and type in
a.out -l
the if statement is not shown
what do I need to do to get this if statement working.

the second problem is I have a while loop that displays text via printf and then I use a gets to take in a string. I need the loop to be only broken when ctrl-d is pressed. I have NO idea of how to do this :confused:
if anyone has an idea let me know.
thanks

at some code that I wrote for class....it should help u a lil with your arg prob.

at some code that I wrote for class....it should help u a lil with your arg prob.

http://mars.utm.edu/~paihann/progs/writels2.htm

for the second, try inserting

if ( EOF ) break;

Previously the end of the loop.

thankyou heeps jj1814, my modified if statement now looks like this and it works: :smiley: :smiley:

if((argv[1] !=NULL) && (strcmp(argv[1], "-l") == 0))
{
printf("output:");
printf("TASK-NO\tDATE\tTIME\tTASK DESCRIPTION");
return(0);
}

here is the basic while loop that I'm working with that I need the Ctrl-d to exit from

while (1 == 1)
{
now=time(0);
ptr=localtime(&now);
lDay = ptr->tm_mday;
lMonth = ptr->tm_mon + 1;
lYear = ptr->tm_year + 1900;
lHour = ptr->tm_hour;
lMinute = ptr->tm_min;

printf\("%u/%u/%u|%u:%u>> ",lDay, lMonth, lYear, lHour, lMinute\);
gets\(strDescription\);
fprintf\(theDatafile,"%u/%u/%u|%u:%u|%s\\n",lDay, lMonth, lYear, lHour, lMinute, &strDescription\);
printf\("\\nTask Added:\\t\\"%s\\"\\n", &strDescription\);

}

what would I use to get ctrl-d to exit that loop, and where would I use it (exactly) it really has to be around the gets() section, cause that is where the user is prompted for input.

The instruction to interrupt a loop is break

you can do something like

printf ("You want to continue? \n");
if ( getc() == 's' ) {break }
else {continue};

or similar the important is the break instruction or a false return
between ( )

while ( TRUE ) or while ( 1 ) is equal a while ( 1 == 1 )
-----------------------------------------------------------------

try also

do
{
...
...
printf ("You want to continue? \n");
}
while ( getc() == 's' )

And it proves gives to be writing programs in your computer several up-to-date minutes. It is also useful to use man pages.

no that is not what I want to do :frowning:
what I want is the stty (tty) explained how it is used really, cause I need to 'remap' the ^d (Ctrl-d) to exit the while loop.
so if anyone can explain the use of stty for me I would be most greatfull
by explination I would be happy with a small program that does this on it's own so I can see it in action.