473,387 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Pointer Argument

Hi All,
I ve written few lines of code to examines whether the handed over read position lies within the file. But while compiling im getting two error

beinhaltetPosition.cpp:22: error: too few arguments to function âbool beinhaltetPosition.cpp:70: error: at this point in file

the code is
Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<stdio.h>
  3. #include<fstream.h>
  4. long mLaenge;
  5. long mNummernkreis;
  6.  //mLaenge = 20;
  7.  
  8.  // examines whether the handed over read position lies within the file.
  9.  //@parm long * | pPos | the read position which can be examined.
  10. //@rvalue false | the read position does not lie within the file.
  11. //@rvalue true | the read position lies within the file.
  12.  
  13.  unsigned short gibLaenge()
  14.  {
  15.          return mLaenge;
  16.  }
  17.  
  18.  bool beinhaltetPosition(long * pPos)
  19.  {
  20.         mLaenge = 20;
  21.         long lUntergrenze = gibLaenge();
  22.         long lObergrenze = 11 - gibLaenge();
  23.        if(*pPos < lUntergrenze || *pPos >= lObergrenze)
  24.          {
  25.                   return false;
  26.          }
  27.     else
  28.                       return true;
  29.       }
  30.  
  31.       int main()
  32.       {
  33.         /* FILE *pFile;
  34.        //ifstream * pFile;
  35.         // int c;
  36.        //fpos_t pos;
  37.     //int pos;
  38.      /*
  39.           fstream file_op("sus.txt","r");
  40.          if (pFile==NULL) perror ("Error opening file");
  41.          else
  42.         {
  43.            c = fgetc (pFile);
  44.            cout<<"Enter the position"<<endl;
  45.            cin>>pos;
  46.            pFile.seekg(pos);
  47.                 if(pFile.seekg(pos))
  48.               cout<<"Right"<<endl;
  49.           else
  50.            cout<<"Wrong"<<endl;
  51.            //fgetpos (pFile,&pos);
  52.            for (n=0;n<3;n++)
  53.       {
  54.              fsetpos (pFile,&pos);
  55.               c = fgetc (pFile);
  56.               //printf ("2nd character is %c\n",c);
  57.            }
  58.           // fclose (pFile);
  59.        }*/
  60.  
  61.       bool t;
  62.       t=beinhaltetPosition(long * pPos);
  63.  
  64.        return 0;
  65.      }
  66.  
Can any body help me?
Aug 27 '07 #1
3 1261
Meetee
931 Expert Mod 512MB
bool t;
t=beinhaltetPosition(long * pPos);
Hi,

You need to pass some long value or a pointer pointing to some long value in beinhaltetPosition(....) function.

Regards
Aug 27 '07 #2
Hi,

You need to pass some long value or a pointer pointing to some long value in beinhaltetPosition(....) function.

Regards
Thanks zodilla58
I passed a long pointer pointing to a file.
Aug 27 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
There is some mighty odd code here.

First, there is iostream.h which is the pre-ANS C++ used until 1998. Are you in fact coding using the C++ of 10 years ago??

Second, there is an fsetpos() in the code to set a stream position. Unfortunately, the argument can only be the return from a previous fgetpos() but there is no fgetpos() in the code.

Third, there is no check that fsetpos() actually worked. It probab;y didn't.


You should do a seekg() to the end of the file. Then do a tellg(). The return from tellg() will tell you the number of bytes in the file.
Aug 27 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
52
by: Douglas Garstang | last post by:
I can't believe I've been trying to work this out for hours now, and I can't believe I couldn't find someone asking for a similar solution in the newsgroups. No wonder I hate C so much, and every...
9
by: Juggernaut | last post by:
I am trying to create a p_thread pthread_create(&threads, &attr, Teste, (void *)var); where var is a char variable. But this doesnt't work, I get this message: test.c:58: warning: cast to pointer...
17
by: Charles Sullivan | last post by:
The library function 'qsort' is declared thus: void qsort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)); If in my code I write: int cmp_fcn(...); int...
7
by: Xiaoshen Li | last post by:
Dear All, I thought I understood using pointer variables as function parameters. But I failed to understand why it is needed pass-by-reference of a pointer variable. To me, pointer variable...
26
by: Bill Reid | last post by:
Bear with me, as I am not a "professional" programmer, but I was working on part of program that reads parts of four text files into a buffer which I re-allocate the size as I read each file. I...
29
by: shuisheng | last post by:
Dear All, The problem of choosing pointer or reference is always confusing me. Would you please give me some suggestion on it. I appreciate your kind help. For example, I'd like to convert a...
6
by: Charles Sullivan | last post by:
I define and initialize an array of structures like the following, (where the <verbiage within angle bracketsis just meant to be explanatory): int func1(<argument prototypes>); int...
27
by: rocco.rossi | last post by:
I've been trying to write a function capable of checking if a pointer value is set to NULL, and if it isn't, of deallocating and setting it's value to NULL regardless of the pointer's type. I...
14
by: Szabolcs Borsanyi | last post by:
Deal all, The type typedef double ***tmp_tensor3; is meant to represent a three-dimensional array. For some reasons the standard array-of-array-of-array will not work in my case. Can I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.