# Multiplying a char array by an int?

Page 1 of 1

## 1 Replies - 326 Views - Last Post: 09 June 2013 - 04:53 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=322723&amp;s=4b54ec45943a50aa5a59b7006c4127ce&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ry110891

Reputation: 2
• 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

Reputation: 3858
• Posts: 6,364
• 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.