1 Replies - 201 Views - Last Post: 09 June 2013 - 04:53 PM Rate Topic: -----

#1 ry110891  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 25
  • Joined: 24-May 12

Multiplying a char array by an int?

Posted 09 June 2013 - 04:41 PM

Hey guys I am wondering if anyone knows how to multiple a value that I pull from my database. For example heres the code:

char buffer[200];
sprintf(buffer, "select Serving_Size from Chicken where Poultry_id='%d'",id);
result=SQLiteExec(buffer);
result=SQLiteSetOnColumn(OnColumn);



so if this pulls integer value 4 out of my database and say I want to multply by 3 to produce the result 12. How would I do this? I am having trouble because I am storing my database value in a char array.

Is This A Good Question/Topic? 0
  • +

Replies To: Multiplying a char array by an int?

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,990
  • Joined: 08-June 10

Re: Multiplying a char array by an int?

Posted 09 June 2013 - 04:53 PM

Hey.

I'm no expert on C/C++, or on using SQLite with it, but I believe you need to convert your char array (string) to an integer using the atoi() function. That will give you a normal int variable to work with, which you can manipulate any way you see fit.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1