Hi there,
I'm newly here, and a beginner too.
I'm tryng to open a file that realy exists, but I cannot do that.
I'm using the Turbo C++ 3.0 compiler and my code is:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <dos.h>
#include <fcntl.h>
#include <io.h>
void ret_file()
{
char pathfile[20];
int hnd;
int c;
char a;
char t[1];
/* Try to open de file to read */
puts("Location File:");
do
{
a = getchar();
putchar(a);
itoa(a, t, 1);
strcpy(pathfile, t);
}
while (a != '\n');
printf("%s\n", *pathfile);
c = getch();
hnd = open(pathfile, O_TEXT);
printf("%d\n\n", hnd);
if (hnd == -1)
{
fprintf(stderr, "FILE NOT FOUND.\n");
return 0;
}
else
{
fprintf(stderr, "THATS OK -> THE FILE WAS FOUND.\n");
return 0;
}
}
If anybody here can helpe-me, I will be so greateful. ;-)
Sorry, but my english is not so good. :o