Solved

open file problem

Posted on 2002-07-25
2
180 Views
Last Modified: 2010-04-15
#include <stdio.h>

FILE *stream;

void main( void )
{
   int numclosed;

   if((stream=fopen("C:\project\SetWiz.log","r"))== NULL )
      printf( "The file 'data' was not opened\n" );
   else
      printf( "The file 'data' was opened\n" );
}

The file exists in the directory but the program can't open the file.
It seems that use the fopen to open a file, i only can open the file with current directory.
Izzit anyway i can open the file in any directory?
For example:
fopen("C:\project\project2\data.txt") ?
0
Comment
Question by:cialat
2 Comments
 
LVL 5

Accepted Solution

by:
Droby10 earned 60 total points
ID: 7177796
it doesn't look like your '\' in your file path variable/parameter for fopen are escaped?
0
 
LVL 86

Expert Comment

by:jkr
ID: 7177935
Droby10 is absolutely correct - it should read 'fopen("C:\\project\\SetWiz.log","r")' or 'fopen("C:/project/SetWiz.log","r")'
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL handling single and double quotes 3 94
Problem in finding output of a program 11 101
how to understand recursion 12 218
Super Scope, DHCP 5 53
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now