Multidimension character array


 
Thread Tools Search this Thread
Top Forums Programming Multidimension character array
# 1  
Old 05-15-2007
Multidimension character array

Hi !

I'm having problem with assigning values to a multidimensional character array.
i wanted to have an array with 48 fields ,each filed being of varying size and hence have declared the array as

char struct_arr[][48];

I am trying to assign values to the fileds as

struct_arr[j] = token

Where token i a character pointer declared as

char *token;

When i try to compile ,i get errors.
Please let me know how can i get it assigned.

Regards,
Jane
# 2  
Old 05-15-2007
assigning values to character array elements
Code:
#include <string.h>
void bld_arr(char arr[][32], const int len)
{
     int i=0;
     for(i=0;i<len;i++)
         strcpy(arr[i],"string value");
}

int main()
{
    char arr[48][32]={0x0};  // 48 element array, each element has 32 characters
    bld_arr(arr, 48);
    return 0;
}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace character in awk array

somedata | awk -F"#soils#" '{split($1,a,"NITNUM="); print a}' how can i edit the content of array 2 above? what i want to do is get rid of single quotes and double quotes. and then turn the "NewLine" into new lines. the data in array 2 (a) is: ... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Use decimal value of array in bc ends with illegal character

hi all I have to read a long cvs file every 4 columns with decimal "3,45" numbers. The 9th row in this cvs is the first line I need, so it I tail -n+9. I use sed -e 's/,/./g' to get decimal values with . delimiter. So far no problem. Goal is to get two maximum negative forces in ranges... (5 Replies)
Discussion started by: Grille
5 Replies

3. Programming

Character pointer to Character array

how to copy content of character pointer to character array in c programming.. char *num; char name=num; (1 Reply)
Discussion started by: zinat
1 Replies

4. Shell Programming and Scripting

How to find length of multidimension array ???

Does anyone know how to find length of multi dimension array of following type A Afor simple array I is to do for (i in A)n++ to find length of array but if it is multi dimension how to find the length ? (2 Replies)
Discussion started by: nex_asp
2 Replies

5. Programming

Unable to assign zero to unsigned character array

Hi, I am unable to assign value zero to my variable which is defined as unsigned char. typedef struct ABCD { unsigned char abc; unsigned char def; unsigned char ghi; } ABCD; typedef ABCD *PABCD; In my Por*C code, i assign the values using memcpy like below ... (3 Replies)
Discussion started by: gthangav
3 Replies

6. Shell Programming and Scripting

how can I check the first character of each variable stored in array

variables are stored in this format D0000, D12345, S1234, D12345 | KestrelPrdV2_0.build.177 - svn 141115 tag as V2.0.0.14 D0000, D12345, S1234, D12345 My question is how can I check the first character of each variable stored in array.It should be start with D or S. Please help... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies

7. Shell Programming and Scripting

How to remove a defined character on an array variable in a do while statement in ksh

I have a korn shell code here on a while do statement which replace the string stored on an array removing double quotes characters on it but it doesn't work. example record: appointmentDate = "tree" which value should result to tree #!/bin/ksh # Remove " on string records let recordCount=3... (5 Replies)
Discussion started by: ryukishin_17
5 Replies

8. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

9. Shell Programming and Scripting

A final question! Compare character with each array element

qwrtyuiop666yhh (1 Reply)
Discussion started by: rorey_breaker
1 Replies

10. Programming

converting contents of a character array to int

Hi, I have character array and i need to convert the content to int. program snipet: char array = {"1","2","3","4","5","6","7","8","9"}. I need to to extract each of these array fields and store them into an integer variable. Casting the contents to (int), gives the ascii value of... (5 Replies)
Discussion started by: jyotipg
5 Replies
Login or Register to Ask a Question