473,666 Members | 2,652 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FILE argument to a function

I seem to run into a funny problem,

basially i need to call a funcyon ReadGeometry and the only parameter
that i need to pass to that function is a file pointer, so my funtion
prototype looks like this:

void ReadGeometry(FI LE *ff1)

Now, my compiler gives a compile time error stating that "FILE can not
start a parameter declaration"

Probably the easiest way to fix this would be to just pass a constant
char as the first argument, but that just seems wrong to pass to a
function a parameter that i dont need.

Any ideas?

Also is it just my copiler specific problem or is it in C standard that
argument list can not start with FILE type?

Nov 8 '06 #1
50 4395
fermineutron wrote:
I seem to run into a funny problem,

basially i need to call a funcyon ReadGeometry and the only parameter
that i need to pass to that function is a file pointer, so my funtion
prototype looks like this:

void ReadGeometry(FI LE *ff1)

Now, my compiler gives a compile time error stating that "FILE can not
start a parameter declaration"
You probably forgot to #include <stdio.hbefor e
declaring the function.

--
Eric Sosman
es*****@acm-dot-org.invalid
Nov 8 '06 #2
2006-11-08 <11************ **********@b28g 2000cwb.googleg roups.com>,
fermineutron wrote:
I seem to run into a funny problem,

basially i need to call a funcyon ReadGeometry and the only parameter
that i need to pass to that function is a file pointer, so my funtion
prototype looks like this:

void ReadGeometry(FI LE *ff1)

Now, my compiler gives a compile time error stating that "FILE can not
start a parameter declaration"
Did you include stdio.h?
>
Probably the easiest way to fix this would be to just pass a constant
char as the first argument, but that just seems wrong to pass to a
function a parameter that i dont need.
It wouldn't help. a "parameter declaration" is the declaration of
a single argument - i.e. int x(int y, int z) contains two parameter
declarations.
Any ideas?

Also is it just my copiler specific problem or is it in C standard that
argument list can not start with FILE type?
If you included stdio.h, and you get that error, your compiler is wrong.
Nov 8 '06 #3

Eric Sosman wrote:
You probably forgot to #include <stdio.hbefor e
declaring the function.
I did include it. I have a main function in main.c, i have readGeometry
function in ReadGeometry.c and i have stdio and other includes in NTC.h
file. All 3 files are a part of a project and NTC.h is included in
main.c
ReadGeometry is prototyped in the NTC.h file.

But it generates the compile error i described above. If i do not
include stdio.h a totaly different error is geerated.

Another question about header files,
I think the following is correct, but i'd appreciate is someone
veryfied it:
if i have 2 or more C files and i have a header file which contains all
of the globals and includes, i have to separately #include "MyHeader.h "
into each of my C files. Is this correct?

Nov 8 '06 #4
"fermineutr on" <fr**********@y ahoo.comwrites:
Eric Sosman wrote:
> You probably forgot to #include <stdio.hbefor e
declaring the function.

I did include it. I have a main function in main.c, i have readGeometry
function in ReadGeometry.c and i have stdio and other includes in NTC.h
file. All 3 files are a part of a project and NTC.h is included in
main.c
ReadGeometry is prototyped in the NTC.h file.

But it generates the compile error i described above. If i do not
include stdio.h a totaly different error is geerated.
Show us some actual code that exhibits the errors.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 8 '06 #5

I tried compiling using lcc-win32, it worked.

I guess the other compiler i used is too old, Borland C++ 5.02 is the
one which errors.

Ill just use lcc from now on for this project.

Thanks every body.

Sorry for such a meaningless post.

Nov 8 '06 #6
"fermineutr on" <fr**********@y ahoo.comwrites:
I tried compiling using lcc-win32, it worked.

I guess the other compiler i used is too old, Borland C++ 5.02 is the
one which errors.

Ill just use lcc from now on for this project.

Thanks every body.

Sorry for such a meaningless post.
For the Nth time, for some very large value of N, *please* show some
context when you post a followup.

Here's what you wrote upthread:

| void ReadGeometry(FI LE *ff1)
|
| Now, my compiler gives a compile time error stating that "FILE can not
| start a parameter declaration"

and you later said that you did have the required "#include
<stdio.h>". I don't believe that Borland C++ 5.02 (being used, I
presume, as a C compiler) would be so buggy as to reject such a simple
declaration. The only possibility I can think of is that it's so old
that it doesn't support prototypes.

Try compiling the following with your Borland compiler:

void func(int x);

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 8 '06 #7
fermineutron said:
>
I tried compiling using lcc-win32, it worked.
If it didn't work with a C compiler, but did work with lcc-win32, then your
code is not C code but lcc-win32 code, in which case I suggest you ask
future questions about your code in an lcc-win32 newsgroup rather than
here.
I guess the other compiler i used is too old, Borland C++ 5.02 is the
one which errors.
Borland's C compiler - and yes, that specific version, works just fine on
correct parameter declaration, and rightly rejects those that are not
correct in form.
Ill just use lcc from now on for this project.
When even lcc rejects your code, which compiler will you then move to?
Wouldn't it be easier to learn C than to keep moving from compiler to
compiler as each of them in turn discovers gaps in your knowledge?
Thanks every body.

Sorry for such a meaningless post.
That's okay - we're getting used to it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.
Nov 8 '06 #8
Keith Thompson said:

<snip>
Here's what you wrote upthread:

| void ReadGeometry(FI LE *ff1)
|
| Now, my compiler gives a compile time error stating that "FILE can not
| start a parameter declaration"

and you later said that you did have the required "#include
<stdio.h>". I don't believe that Borland C++ 5.02 (being used, I
presume, as a C compiler) would be so buggy as to reject such a simple
declaration. The only possibility I can think of is that it's so old
that it doesn't support prototypes.
It is not, it does not, it is not, and it does, in that order. In other
words, the problem here is not with the compiler, but with the source code
being supplied to it.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.
Nov 8 '06 #9

"fermineutr on" <fr**********@y ahoo.comwrote in message
news:11******** **************@ b28g2000cwb.goo glegroups.com.. .
void ReadGeometry(FI LE *ff1)
Now, my compiler gives a compile time error stating that "FILE can not
start a parameter declaration"
only thing I can think of without seeing the real code is you forgot to put
a semicolon after the prototype declaration.
Although that doesnt compile in lccwin32 either and you said it does in that
compiler

Probably the easiest way to fix this would be to just pass a constant
char as the first argument, but that just seems wrong to pass to a
function a parameter that i dont need.

Any ideas?

Also is it just my copiler specific problem or is it in C standard that
argument list can not start with FILE type?

Nov 8 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3996
by: lion | last post by:
I get these errors when uploading images via a web page: (the page still uploads the images but reports these errors?) Warning: fopen(D:\php\uploadtemp\php1FC7.tmp) : failed to create stream: No error in D:\webspace\me.co.uk\wwwroot\test\Live.php on line 105 Warning: Wrong parameter count for filesize() in D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109
7
6203
by: Zeljko Knezevic | last post by:
Is it possible to rewrite the entire file (to delete it's content) without knowing the exact path? #include <fstream> void f(std::ostream file) { // ... }
2
4187
by: SunRise | last post by:
Hi I am creating a C Program , to extract only-Printable-characters from a file ( any type of file) and display them. OS: Windows-XP Ple help me to fix the Errors & Warnings and explain how to use Command-Line Arguments inside C program.
8
3622
by: one2001boy | last post by:
Hello, I can use call a function with any arugment from LoadLibrary(), but not a function with argument of "FILE*. For example, I can build a .DLL dynamically loaded library with option /DDD in VC++ in command link.exe. This dynamically loaded library can then be loaded by function LoadLibrary(). The address of a function say func1(int) inside .DLL file can be exported and accessed by function
1
6400
by: Ritesh Raj Sarraf | last post by:
Hi, The program downloads the files from the internet and compresses them to a single zip archive using compress_the_file(). Upon running syncer() which calls the decompress_the_file(), the first iteration succeeds. But upon second iteration, I get an IOError exception with the message: "compressed file ended before the logical end-of-stream was detected"
1
6477
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
13
3483
by: Andrew | last post by:
Hello, I am trying to find a way to take the contents of a directory and write it into a file. I have a directory that has several hundred text files, and I want to create a file containing all of the names of those files. I can get the contents of the directory onto the screen using system("dir"); But I have not been able to get this data into a file. I understand that stdout is a pointer to a file, and so I should be able to open and...
14
2799
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given by df -k lopgod10:~/mycrfile # df -k /mnt/mvdg1/vset Filesystem 1K-blocks Used Available Use% Mounted on
1
8240
by: ohaqqi | last post by:
Hi guys, I'm still working on my shell. I'm trying to implement a function typefile that will take a command line input as follows: > type <file1> This command will implement a catenation of file1, equal to the command cat <file1> I need to use execvp() and fork() system calls to create a new process that will type/cat any text file. In my code below, the execvp() call in the function at the bottom gets me the following: ...
0
8438
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8348
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8863
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6187
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5660
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4186
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4356
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2765
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 we have to send another system

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.