Comment on Tutorial - perror() Function - example program in C By Lakshmi



Comment Added by : John Morrison

Comment Added at : 2010-03-28 14:55:07

Comment on Tutorial : perror() Function - example program in C By Lakshmi
Nice example. I think this is more idiomatic tho'.


/* Demonstration of error handling with perror() and errno. */

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

int main(int argc, char** argv)
{
FILE *fp;

if (fp = fopen(argv[1], "r"))
{
printf("File %s opened for reading.\n", argv[1]);
fclose(fp);
}
else
{
perror("You goofed!");
printf("errno = %d.\n", errno);
exit(1);
}
return 0 ;
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Actually, the given accuracy just barely exceeds w
View Tutorial          By: William Fraser at 2015-06-07 16:37:52

2. Very precise and informative tutorial. Appreciated
View Tutorial          By: Rishi Raj at 2011-07-08 12:25:04

3. thanq for this tutorial. It is very useful. But i'
View Tutorial          By: syahmi at 2010-03-06 02:55:05

4. Nicely explained concept. Thankx.
View Tutorial          By: Raghvendra at 2013-01-17 07:48:18

5. How to send to multiple mobiles at a time
View Tutorial          By: rakesh at 2010-04-30 10:33:51

6. thanks for the help! your tutorials really help us
View Tutorial          By: Mon Bernie Gucor at 2009-02-20 19:57:35

7. hi sr.
do u have any idea have any idea how

View Tutorial          By: mirna at 2012-03-27 05:47:34

8. Hi Fred, I found this link which has more explanat
View Tutorial          By: Boulvat at 2012-09-25 08:36:48

9. i have downloaded the code and calling the the SMS
View Tutorial          By: sandeep das at 2009-04-09 11:12:16

10. Pl provide me code to send sms using USB modems.
View Tutorial          By: Prayag Singh at 2010-09-27 22:50:34