2 Replies - 3877 Views - Last Post: 12 October 2010 - 03:55 PM Rate Topic: -----

#1 m_johnst  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 19-September 10

Pointer From Integer Without Cast Error

Posted 12 October 2010 - 03:34 PM

Hey everyone,
I am having errors in a block of my code for a program that stores/calculates calories burned per person based on input.

Here's the block of code:
	char activitiesAllowed[(argc+1)/2][BUFSIZ];
	int caloriesPer[(argc+1)/2];
	int i;
	for (i=1; i<argc; i++) { //loops through input arguments putting one in activity, then one in caloriesPer
		strcpy(activitiesAllowed[i],argv[i]); //puts activity in array
		strcpy(caloriesPer[i],atoi(argv[++i])); //converts argc to int and puts in caloriesPer
	}



The 6 errors occur on line 6 and the errors are:
Passing argument 1 of '__builtin_object_size' makes pointer from integer without a cast
Passing argument 1 of '__builtin_object_size' makes pointer from integer without a cast
Passing argument 1 of '__builtin__strcpy_chk' makes pointer from integer without a cast
Passing argument 2 of '__builtin__strcpy_chk' makes pointer from integer without a cast
Passing argument 1 of '__inline_strcpy_chk' makes pointer from integer without a cast
Passing argument 2 of '__inline_strcpy_chk' makes pointer from integer without a cast



Any help is much appreciated.
Thanks,
Michael

Is This A Good Question/Topic? 0
  • +

Replies To: Pointer From Integer Without Cast Error

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,659
  • Joined: 23-August 08

Re: Pointer From Integer Without Cast Error

Posted 12 October 2010 - 03:46 PM

int caloriesPer[(argc+1)/2];
...
strcpy(caloriesPer[i],atoi(argv[++i]));



You're trying to strcpy into an int array.
Was This Post Helpful? 1
  • +
  • -

#3 m_johnst  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 15
  • Joined: 19-September 10

Re: Pointer From Integer Without Cast Error

Posted 12 October 2010 - 03:55 PM

>.< I feel stupid now lol.
Thanks for the help. I changed that line to
caloriesPer[i] = atoi(argv[++i];


and it works now.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1