473,473 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

fopen() in c returns null

3 New Member
why fopen returns null,is there any specific reason
May 17 '07 #1
7 7943
gpraghuram
1,275 Recognized Expert Top Contributor
HI,
In which mode r u opening the file
Check the path of the file,being passed as argument
This may be the reason , for which fopen returns null

Thanks
Raghuram
May 17 '07 #2
lakshmi1
3 New Member
HI,
In which mode r u opening the file
Check the path of the file,being passed as argument
This may be the reason , for which fopen returns null

Thanks
Raghuram

Hi,

I am opening file in write mode.Path contains a very big string.
Several files were copied into the same path,but suddenly for one of the file
it is not able to write into the same path

Thanks,
srilakshmi
May 17 '07 #3
gpraghuram
1,275 Recognized Expert Top Contributor
Hi,
I think there is a restriction to path size of 260 characters.(I am not very sure abt this)
Check for the failing fopen the path is greater than 260 characters.
This value is in stdio.h

Thanks
Raghuram
May 17 '07 #4
ilikepython
844 Recognized Expert Contributor
HI,
In which mode r u opening the file
Check the path of the file,being passed as argument
This may be the reason , for which fopen returns null

Thanks
Raghuram
Also, dont' forget that if the file isn't there or fopen() can't open it, it will return null as well. You should always check after you open a file, to see if it returned null or the actual file pointer.
May 17 '07 #5
AdrianH
1,251 Recognized Expert Top Contributor
Also check the errno value.


Adrian
May 17 '07 #6
Silent1Mezzo
208 New Member
Also, dont' forget that if the file isn't there or fopen() can't open it, it will return null as well.
fopen() in write mode will create the file if it doesn't exist.
May 17 '07 #7
ilikepython
844 Recognized Expert Contributor
fopen() in write mode will create the file if it doesn't exist.
Yep, that is also true.
May 17 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mister Zimbu | last post by:
I'm having problems with a program I wrote- when it comes time to output a file, the call to fopen locks up and I have to break the program manually. I've pinpointed the actual stopping point to...
28
by: Sathyaish | last post by:
If fopen fails, is there a way to know why?
3
by: Gregory Graham | last post by:
I have a temperature sensor device we use to shutdown our servers. It relys on fopen() blocking when the serial port device isn't ready. Unfortunately that's not what's happening. The fopen()...
19
by: lihua | last post by:
Hi, Group! I got one question here: We all know that fclose() must be called after file operations to avoid unexpected errors.But there are really cases when you forget to do that!Just like...
10
by: pjlsr | last post by:
It's close to twenty years since I used the C language and at that time I was doing only floating point computational work, nothing with strings or reading files. I tried to use fopen in the...
39
by: ferrad | last post by:
I am trying to open a file for appending. ie. if the file exists, open it for appending, if not, create it. I am getting back a NULL pointer, and do not know why. Here is my code: FILE...
5
by: eyalc1978 | last post by:
Hi Does someone knows if fopen() is a non-blocking function in a sense that if there isn't sufficient disk space to open a file in write mode, then the function will not wait but fail? I find...
5
by: divc | last post by:
Hi all, I've written a C program. I need to write some data into files. I've written some code and I'm getting a segmentation fault during a call to the fopen function. I've given part of the code...
1
by: carpediem | last post by:
Hi, I am developing an application in Borland C++ 6, one of my functions opens a file and loads it into the memory. I have never had problems with fopen, but this bug is really weird, fopen...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.