Error on passing pointer/array parameter

Error on passing pointer/array parameter

Page 1 of 1

3 Replies - 5730 Views - Last Post: 16 May 2005 - 08:27 PM Rate Topic: -----

#1 joan400  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-April 05

Error on passing pointer/array parameter

Post icon  Posted 16 May 2005 - 02:55 AM

Hi,

I have this function

1  void mvC(char s[1], char c[], int i)
2  {
3     char *ps = s;
4     memcpy(c, s, i);
5  }

In the main() function, mvC() is called as
6  char temps[100];
7  /* funct is declared as funct[36] in a typedef structure */
8
9  void main()
10 {
11    .
12    .
13    mvC( temps[1], hlprec.ddru.ddrua.funct, strlen( temps ) );
14    .
15    .
16 }

After using CRTBNDC command (compilation of ILE C code in AS400 machine), the following severity error at line 13 is placed in spool file: Function argument between types "unsigned char*" and "unsigned char" is not allowed.

Is s[1] (line 1) an invalid parameter to receive value of temps[1] (line 13)?

Thank you. God bless!

:blink:

Is This A Good Question/Topic? 0
  • +

Replies To: Error on passing pointer/array parameter

#2 malkiri  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 364
  • Joined: 29-March 01

Re: Error on passing pointer/array parameter

Posted 16 May 2005 - 09:21 AM

My guess is that your problem is with the funct argument. From the sounds of the comment at the top, hlprec.ddru.ddrua.funct is a char. The prototype for mvC() specifies that the second argument is an array of chars.
Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Error on passing pointer/array parameter

Posted 16 May 2005 - 07:13 PM

In your function
void mvC(char s[1], char c[], int i)


you are really only receiving a char...that char that was in the array at index 1...should you not be receiving it as such?
void mvC(char s, char c[], int i)


I'm also not sure what you're doing with the pointer to ps...your assigning it a char value, so it does not really need to be a pointer, but more to the point, you're not using it.
Was This Post Helpful? 0
  • +
  • -

#4 joan400  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 12-April 05

Re: Error on passing pointer/array parameter

Post icon  Posted 16 May 2005 - 08:27 PM

Hi,

I apologize for the *ps thing. Anyway, I have tried doing your code days ago, which looks like this:

1  void mvC(char s, char c[], int i)
2  {
3     memcpy(c, s, i);
4  }

In the main() function, mvC() is called as
5  char temps[100];
6  /* funct is declared as funct[36] in a typedef structure */
7
8  void main()
9  {
10    .
11    .
12    mvC( temps[1], hlprec.ddru.ddrua.funct, strlen( temps ) );
13    .
14    .
15 }

and got the error at line 3 memcpy() Function argument between types "const void*" and "unsigned char" is not allowed.

I wanted to pass a single character array temps[1] to function mvC() thru variable s and use it in memcpy(). I thought it is as simple as making s a char variable so that it will be single, too, but I was wrong.

I placed and used *ps, such as this...
char *ps = s;
memcpy(c, ps, i);



but found no luck in using it. Looks like my pointers are in a mishap.

Thank you so much. God bless!

:blink:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1