2 Replies - 1471 Views - Last Post: 19 November 2012 - 04:32 PM Rate Topic: ***-- 2 Votes

#1 sumsar1812  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 19-November 12

error: subscripted value is neither array nor pointer?

Posted 19 November 2012 - 03:51 PM

Hi guys. My problem is I am trying to add a string to one of members in a struct. This struct is allready an array with an member as a array too(code below)
struct kamp{
  int round;
  char date[10];
  double time;
  char homeTeam;
  char outTeam;
  int homeResult;
  int outResult;
  int people;

};
typedef struct kamp kamp;




But when i try to use the struct i get an error whitch tells me it is not an array nor a pointer ?
the code where i try to assign a string is below:

void assignDate(kamp matches,char str[],int lines,int lineLen)
{
  int i,k;
  for (i = 0;i <= lines;i++)
    {
	  for(k = 0;k <=10,k++)
	  {
        matches[i].date[k] = str[9 + (lineLen * i) + k];
	  }
	}
}



Is This A Good Question/Topic? 0
  • +

Replies To: error: subscripted value is neither array nor pointer?

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1134
  • View blog
  • Posts: 7,094
  • Joined: 07-September 06

Re: error: subscripted value is neither array nor pointer?

Posted 19 November 2012 - 04:05 PM

The problem is caused by this line:
void assignDate(kamp matches,char str[],int lines,int lineLen)



You are telling the compiler that you will be passing in a single kamp scruct, not an array of them. Change it to this:
void assignDate(kamp matches[],char str[],int lines,int lineLen)



and it should get rid of that error (though I can't say whether it will work overall, as we have only been shown very little code).

Hope that helps.
Was This Post Helpful? 1
  • +
  • -

#3 sumsar1812  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 19-November 12

Re: error: subscripted value is neither array nor pointer?

Posted 19 November 2012 - 04:32 PM

the worst part is I have another version of that function where i rememered to put that in, I guess i throght the problem was the date[] array. But thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1