 |
GTK+ Forums Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
|
|
|
| Author |
Message |
|
|
angel face Familiar Face
Joined: 11 Feb 2008 Posts: 15
|
Posted: Wed Feb 20, 2008 8:01 pm Post subject: Array Trouble |
|
|
Hey guys.
Here's my problemo!...
Ive opened a text file and the contents is display in a textview.
Now I want to read what is in the textview into a character array (GArray). Does anybody know how to do this?
Really appreciate it :) |
|
| Back to top |
|
 |
Micah Carrick Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 496 Location: Portland, OR USA
|
Posted: Sun Feb 24, 2008 6:17 pm Post subject: |
|
|
| Well, I never actually use GArray, however, the string of text in the textview is a character array already. This is a fundamental concept of C. It is an array of single char values terminated by NULL (\0). Therefore, you can loop through it with a while or for loop and add each character to your GArray. |
|
| Back to top |
|
 |
angel face Familiar Face
Joined: 11 Feb 2008 Posts: 15
|
Posted: Sun Feb 24, 2008 7:02 pm Post subject: |
|
|
I cant figure out how to directly access the array. I am using a pointer. No matter what i try i cant seem to access it. I dont know what im missing. Its quite annoying...any ideas?
gchar *text;
gtk_text_buffer_get_selection_bounds (buffer1, &start, &end);
text = gtk_text_buffer_get_text (buffer1, &start, &end, FALSE);
gtk_text_buffer_set_text (buffer2, text, -1); |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group CodeBB 1.0 Beta 2
|