Question: if i dupe topic i really sorry, i searched for it with no result here.
I have code

```
void split(char* str, char* splitstr)
{
     char* p;
     char splitbuf[32];
     int i=0;
     p = strtok(str,",");
     while(p!= NULL)
     {
               printf("%s", p);    
               sprintf(&splitstr[i],"%s",p);
               i++;
               p = strtok (NULL, ",");

     }
}

```

How can i use proper sprintf to put the splited words by strtok to string array?
Can i somehow avoid breaklines created by strtok?
I am programming in ANSI C. I declared array splitstr and str the same way. 

```
char* splitstr;//in main char splitstr[32];

```

Thanks for help.

---

edit:

```

i would like do something like this:
INPUT (it is a string) > "aa,bbb,ccc,ddd"
I declare: char tab[33];
OUTPUT (save all items to array of strings if it is even possible) > 
tab[0] is "aa"
tab[1] is "bbb"
...
tab[3] is "ddd" but not "ddd(newline)"

```

---

edit2 [18:16]

I forgot add that the data string is from reading line of file. That's why i wrote about "ddd(newline)". I found after that the new line was also shown by strtok but as another item. By the way all answers are good to think over the problem. Few seconds ago my laptop has Broken (i dont know why the screen gone black) As soon as i take control over my pc i will check codes. :-)

Answer: 
Connection opening in SQLite is about 0.2ms. 

The best practice tells us to open and close the connection each time we need one.
Just use [SQLiteOpenHelper.getReadableDatabase()](http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html#getReadableDatabase()) and [SQLiteOpenHelper.getWriteableDatabase()](http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html#getWritableDatabase()) - Android will manage and cache the connection so you don't need to.

In fact, refer to the official Google [Using Databases](http://developer.android.com/guide/topics/data/data-storage.html#db) documentation:

> 
> To write to and read from the
>  database, call getWritableDatabase()
>  and getReadableDatabase(),
>  respectively. These both return a
>  SQLiteDatabase
> 
> 
>