|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Pointer of file in parameter I'm under Windows XP, IDE devc++, and I made a program in C. Here I have several pointers that points to file of same type: I should point the file or will be recording TV channels. I would therefore be grouped in a "table file pointer" for use by more easier (zapping between channels for example). So I did Code: FILE* FpChannel[NumberOfChannels]= { }; So my question is this: how to pass the "pointer array" argument in a function? And how to write the prototype for this function? (this is a function that would do a fopen individual files corresponding to the pointer: it makes eg FpChannel[i] = fopen (cNameFileClient, "w"); what I want to report it works very well leaving in the main function) |
#2
| |||
| |||
Re: Pointer of file in parameter I do not see very well the worries. You create your function with a prototype like: Code: void fopen_array(FILE** FpChannel) |
#3
| |||
| |||
Re: Pointer of file in parameter Want to pass an array of anything (eg "noMatterWhat tab [10]") to a function, well you simply pass the variable name to the => ex: fct(tab) The function will be reported as receiving a pointer to the type in question => void fct (noMatterWhat *pt) At now, what's that "noMatterWhat"? Its a "FILE *" where the response absolute => void fct (FILE * pt) However, the equivalent array / pointer works only for the last dimension. For other dimensions, an array is a table. Example: A rectangle int 8x10 => int rect [8] [10] If you pass this "rect" to a function, it can be declared as - Void fct (int rect [8] [10]) - Void fct (int * rect [10]) But in no case be declared void fct (int ** rect). This is because to address the element [x] [y], the compiler needs to know the width to calculate the position. and "int ** rect", there is no indication of largeness... |
#4
| |||
| |||
Re: Pointer of file in parameter But absolute, since you pass a pointer to an array at large then you must become accustomed to pass the array size in parameter (size_t n). I may be wrong but I think the compiler would give you an error.
__________________ Grand Theft Auto 4 PC Video Game |
#5
| |||
| |||
Re: Pointer of file in parameter Yes you may be correct, but then I do not know the size of the array, they are pointers to files of which I do not know the size. In any case it works. Thanks for the solution and other information provide that helps me a lot in my code. |
![]() |
|
Tags: dev c, parameter, pointer |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Changing Stylus pointer to normal Pointer in Tablet PC | Kelley | Portable Devices | 3 | 21-06-2011 07:22 PM |
Parameter function and generic pointer | Rubero | Software Development | 7 | 25-09-2010 09:04 PM |
Differentiation between void pointer and null pointer | Ram Bharose | Software Development | 5 | 18-01-2010 12:11 PM |
Pointer parameter in a function | Chrisch | Software Development | 4 | 14-12-2009 10:57 PM |
0x80070057 Parameter is Incorrect when copying .DAT file | Junn007 | Vista Help | 0 | 12-03-2008 02:41 PM |