Nov 22, 2009

Opening Files With As A Function?

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Programming General > C, C++ & Visual C++

Opening Files With As A Function?

xboxrulz
Alright,

This is confusing. The specification laid out by my prof is:

QUOTE
a function that receives the address of a C-style, null-terminated string containing the name of the file that holds the prefix table
FILE* open(const char filename[]);
This function opens the named file for read access and returns the address of the file pointer, if successful; NULL otherwise.


However, usually this is how I open files:
CODE
void readFile (){
FILE* fp = NULL;
fp = fopen("file.txt", "r");
}


So how do I adopt this?

xboxrulz

Comment/Reply (w/o sign-up)

rnd-am
open() and fopen() are different functions

from<fcntl.h> and <stdio.h> respectively. but, anyway, open() function has second argument, opening mode, giving by ORed flags

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Similar Topics

Keywords :

  1. Organizing C++ Project Files For Large Projects
    (source code, header, makefiles) (4)
  2. Password Function
    (0)
    If you are making a logging system in a C++ program you don't want the password you are writing
    to appear in characters right? making it appear as stars is alot better. CODE #include
    #include char x; void password(char A ) {int i=0; for(i=0;i {flushall(); x=getch(); A =x;
    printf("*"); } } void main() { char A ; password(A); } First of all declare a character
    globally or locally inside the function it doesn't matter. But you must declare the array inside
    the main or globally. The only parameter needed in the function is the array. As for the leng....
  3. Sleep Function Not Working
    (4)
    CODE /* sleep example */ #include #include int main(void) {    int i;    for (i=1; i    {
          printf("Sleeping for %d seconds\n", i);       sleep(i);    }    return 0; } I have turbo
    C++, i found this in its help file shouldn't it work?, when i run it i get: CODE Compiling
    NONAME00.CPP: Error NONAME00.CPP 8: Call to undefined function 'sleep' in function main()
    I tried library , doesn't work. In which library is sleep() function?....
  4. Friends Can't Start The Exe Files I Send :(
    (5)
    I am using visual c++ 2008. and when I send the .exe file that I created to my friend, (from the
    debug folder) he gets an error message when trying to execute it /sad.gif"
    style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> any ideas? when my friend
    tried, he said that he got the following error message: cannot execute .... And lots of PC info.
    When I create these files, I choose win32 console application (something that looks like the cmd
    when executed) please.. I really need to get this thing working Thanks //Feelay....
  5. Alternative To Strtok() Function In C++
    (1)
    Hello, i have written an alternative function to strtok(), which i think is better and easier to
    use. I hope it will be usefull. Here is the code snippet from my program: CODE      1 /*      
                 2  * The Ultimate Network Tool.      3  * Copyright (C) 2004 Virtual Pointer      4
     *      5  * The Ultimate Network Tool is free software; you can redistribute it and/or      6  *
    modify it under the terms of the GNU General Public License      7  * as published by the Free
    Software Foundation; either      8  * version 2.1 of the License, or (at your opt....

    1. Looking for Opening, Files, With, As, A, Function?

See Also,

*SIMILAR VIDEOS*
Searching Video's for Opening, Files, With, As, A, Function?
advertisement



Opening Files With As A Function?

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com