HELP! Sample program in String 3 dimensional array in TURBO C

 
0
 

Good day, can you give me some sample program that hold string in 3 dimensional array.. because our instructor didn't expound the discussion about multidimensional array then is it useful in our final project this semester..Hoping for reply

Thank You

Featured Replies in this Discussion

  • Here's a link on a thread describing the concepts about 2d and 3d arrays ...
    Post Contains: Links
 
0
 

No. But I will give you this.

#include <stdio.h>

int main() {
	int i;
	char oneDimensional[]="I am one-dimensional!\n";
	char twoDimensional[5][5]={
			"I am",
			{'t','w','o','-',0},
			"dime",
			"nsio",
			"nal!"
	};
	printf("%s",oneDimensional);
	for(i=0;i<5;i++){
		printf("%s",twoDimensional[i]);
	}
	return 0;
}

Which outputs this:

I am one-dimensional!
I amtwo dimensional!

Yes, I know it's missing a space. However, to keep it inside 5x5 and include the trailing 0's at the same time, I realized I was too lazy to fix it.

 
0
 

No. But I will give you this.

#include <stdio.h>

int main() {
	int i;
	char oneDimensional[]="I am one-dimensional!\n";
	char twoDimensional[5][5]={
			"I am",
			{'t','w','o','-',0},
			"dime",
			"nsio",
			"nal!"
	};
	printf("%s",oneDimensional);
	for(i=0;i<5;i++){
		printf("%s",twoDimensional[i]);
	}
	return 0;
}

Which outputs this:

I am one-dimensional!
I amtwo dimensional!

Yes, I know it's missing a space. However, to keep it inside 5x5 and include the trailing 0's at the same time, I realized I was too lazy to fix it.

Thank you for the reply DeanMSands3, i have some in idea in 1d and 2d array in integer.. all i need is in string because in my program it deals with string that can be search,deleted, edit and more, also use 3d array with this program...

 
0
 

Here's a link on a thread describing the concepts about 2d and 3d arrays
http://www.daniweb.com/software-development/cpp/threads/104403

thank you zeroliken for that thread but i didn't understand well... just a newbie in programming.. i want some example in string in using 3d array in TURBO C.. Hope you can help...

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article