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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program 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
Archived Comments
1. I wont to know about every thing of java
View Tutorial By: susantha at 2009-10-11 09:35:40
2. Great guide. Missed the lecture, and this summed e
View Tutorial By: Anonymous at 2008-12-21 19:36:19
3. Hi All........
People those who are ge
View Tutorial By: Abhijit at 2013-05-28 11:24:24
4. class Evaluate
{
public static void
View Tutorial By: prajjawal at 2013-02-27 12:36:58
5. Hi,
Can anyone suggest a GSM Modem
View Tutorial By: Archna at 2009-11-06 03:23:14
6. Thanks for this great tutorial... was looking for
View Tutorial By: Shashi at 2012-09-20 11:35:08
7. This is a great tutorial. I have a slight problem,
View Tutorial By: Vix at 2010-11-22 13:42:03
8. i want ask whether how do i run the application?
View Tutorial By: unknown at 2009-10-29 21:13:03
9. Nice explanation with appropriate example
View Tutorial By: VL at 2009-04-09 06:17:37
10. Great tutorial about ArrayList .It's a very great
View Tutorial By: umesh sharma at 2009-05-14 20:40:39