string « dynamic « C Array Q&A

Home
C Array Q&A
1.bit
2.Byte
3.char
4.class
5.Development
6.Dimensional Array
7.dynamic
8.element
9.find
10.index
11.initialization
12.Integer
13.length
14.loop
15.memory
16.Operation
17.pointer
18.Print
19.size
20.Sort Search
21.string
22.struct
23.variable
C Array Q&A » dynamic » string 

1. Using strsep() with dynamic array of strings in C    stackoverflow.com

I have the following code:

#include <string.h>

int main(void) {
    char *buffer = NULL, **words = NULL, *aPtr = NULL, *sPtr;
    int count = 0;

   ...

2. Associative array with mixed (numerical and string) indices?    stackoverflow.com

How would one implement a dynamic associative array that could take any number of mixed indices (integers, strings, or both)? I aim to simulate structures by providing, for example, people[3].location as syntactical ...

3. dynamic string array struct in C    stackoverflow.com

Gurus, I have a Java background and need your help. I have to write a function in c which will return a dynamic array of strings. Here are my requirements:

  • I have 10 different ...

4. Trouble filling a dynamic c array    stackoverflow.com

I am having issues with filling an array of strings that was created dynamically. The array basically contains two strings and I would like to print them both with their lengths. ...

5. How do I dynamically allocate an array of strings in C?    stackoverflow.com

If I have the number of items in a var called "totalstrings" and a var called "string size" that is the string size of each item, how do I dynamically allocate ...

6. C dynamic string array    stackoverflow.com

I have char * lines[1000] string that can hold 1000 characters. How to create 100 arrays of that string. I get error with this code down.

char * lines[1000];
lines = (lines*)malloc(100 * ...

7. Dynamically grown array of strings    stackoverflow.com

I'm trying to build a dynamically grown array of strings. Neither the number of strings nor the length of each string is known at compile time. Here's the code I came ...

8. Dynamic pointer array to strings    bytes.com

Ok so I've got the program running as I wanted, except it automatically allocates 16 bytes for each string even if the length is less than that. so for example turkey still gets allocated 16 instead of just 7 bytes. It does however expand correctly for longer strings. Richard starts at address 00331A18 Gilmore starts at address 00331A28 Paul starts at ...

9. Dynamic allocate string array    bytes.com

huohaod...@gmail.com wrote: [..] I tried char * mFileList[] = new char[index]; but got a syntax error. > char **mFileList = new char*[size]; > But let me reiterate, do NOT presume managing dynamic memory is easy or recommended. Try to stick to standard containers before you learn enough. Do > std::vector It's basically all you need, trust me. > V -- ...

10. Dynamic Array of Strings    bytes.com

Hi, [color=blue] >From searching through the FAQ and the web, this seems to be a widely[/color] discussed topic, but I have not come up with a way that quite meets my needs. I have a sequence of files that contain tab/space separated data, with anywhere between 10 and 300 columns. Out of this data, I need only seven columns, but these ...

11. Dynamic string Arrays    cboard.cprogramming.com

Hi I want to scanf a number from the input and create a string array with that amount of strings. each string has 4 characters. i.e if the number is 3 I want to create an array that has enough space for 3 strings. Also how do i access each string? thank you very much in advance.

12. dynamic string pointer array    cboard.cprogramming.com

You need to do more unit tests, in general. Unit tests (testing one function -- or unit -- at a time) make it clear what works and what does not. Then you can ask people for help on what does not work. By supplying my own is_delimiter function, I was able to get this result, with this test: Code: #include ...

13. Creating and Using a dynamic array of C strings?    cboard.cprogramming.com

Hello, I have this program where I'm creating a list of strings and the list can expand to create more strings. The reason is because users can add words during runtime, and so it needs to be expandable. The size of the word is guaranteed to be less than 100, so I've allocated memory to be a little above 100 for ...

14. Build an array of strings dynamically    cboard.cprogramming.com

#include #include #include int main(void) { char *options[] = {"Option 1", "Option 2", "Option 3"}; char **myStringArray; int i, numOps; numOps = sizeof(options) / sizeof(char *); myStringArray = malloc(numOps * sizeof(char *)); for (i = 0; i < numOps; i++) { myStringArray[i] = malloc(strlen(options[i]) * sizeof(char)); strcpy(myStringArray[i], options[i]); } for (i = 0; i < numOps; i++) { ...

15. Dynamic allocation of an array of strings    cboard.cprogramming.com

16. Dynamic String Array    cboard.cprogramming.com

O.K. I did what you said and it fixed it, sort of. I added another parser and it stopped working. Below is the code. Code: char **add_string( char **list, char *add, int size ) { char **newList; int count; newList = (char **) malloc( sizeof( char* ) * ( size + 1 ) ); if( size > 0 ) for( count ...

17. String Compare Using Dynamic Arrays    cboard.cprogramming.com

18. Concatenating strings (dynamic array using pointers)    cboard.cprogramming.com

Hey all, Any ideas on how to concatenate strings that are refered to by an array of pointers to pointers? This is what I have at the moment: Code: #include #include #include #define MAX_NO_STR 10 #define MAX_LGT_STR 99 main(int argc, char *argv[]) { char **strings; int elements, i; strings = malloc( MAX_NO_STR * sizeof(char *) ); if(strings == ...

19. declaring array of strings dynamically!!!!    cboard.cprogramming.com

#include #include #include struct ffblk ffblk; char **files; void countMem_to_Alloc(){ int done,counter=0,i; done = findfirst(fname,&ffblk,0); while(!done){ done = findnext(&ffblk); counter++; } files = malloc(counter * sizeof(char)); for(i=0;i

20. Creating and Using a dynamic array of C strings?    forums.devshed.com

Hello, I have this program where I'm creating a list of strings and the list can expand to create more strings. The reason is because users can add words during runtime, and so it needs to be expandable. The size of the word is guaranteed to be less than 100, so I've allocated memory to be a little above 100 for ...

21. Dynamic array of dynamic strings    forums.devshed.com

Hello all once again, and once again I'm trying to complete a project for school. We were never instructed to learn pointers, however, I'm having troubles seeing how they are not going to be needed for a requirement in the project. We are suppose to keep a database of customer names and at the end of the day total up each ...

22. Reading strings into a dynamically created array?    daniweb.com

//char or char*?? charArray = (char) calloc(numNames, numChar);//creates 2D array if(charArray == NULL) { printf("Program error."); exit(0); } //get each name c = 0; for(i = 0; i < numNames; i++) { printf("\nEnter name %i: ", &i); for()//until final character is reached { *charArray = fgetc(stdin);//get char from keyboard c++; } if(i < numNames - 1)//if not on last name charArray ...

23. dynamic Array in C from strings    daniweb.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.