954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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

cutterpillow20
Newbie Poster
9 posts since Sep 2011
Reputation Points: 10
Solved Threads: 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.

DeanMSands3
Junior Poster
185 posts since Jan 2012
Reputation Points: 37
Solved Threads: 26
 

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

zeroliken
Veteran Poster
1,106 posts since Nov 2011
Reputation Points: 201
Solved Threads: 162
 

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...

cutterpillow20
Newbie Poster
9 posts since Sep 2011
Reputation Points: 10
Solved Threads: 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...

cutterpillow20
Newbie Poster
9 posts since Sep 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You