Monday, May 24, 2010

I have a string of length 500 and Iwant to create an array of strings of 50 characters each how to do it in C?

char aOriginalArray[500];


char aNewArrays[10][50];





for( int i = 0; i %26lt; 10; i++ )


{


for( int j = 0; j %26lt; 50; j++ )


{


aNewArrarys[i][j] = aOriginalArray[ (i * 50) + j ];


}


}





There are cleaner ways of doing it using memcpy, but if you're asking this question, your prof. probably would want something like the above.

I have a string of length 500 and Iwant to create an array of strings of 50 characters each how to do it in C?
I know that in VB-6 there is a SPLIT() function that returns an array...Not sure how to do it in C, but you might want to check out http://www.pscode.com - I use that site all the time and it has great snippets.
Reply:u shud try two dimenstional array





char [10][50];





BOL





Amit
Reply:Good quetion


the Program is as follows


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


char a[500];


for(i=0;i%26lt;50;i++)


{


printf("Enter the strings");


scanf("%s",%26amp;a[500]);


}


for(i=0;i%26lt;50;i++)


printf("%d",a[500]);


getch();


}

wedding reception flowers

No comments:

Post a Comment