1,105,375 Community Members

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

Member Avatar
cutterpillow20
Newbie Poster
9 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
DeanMSands3
Posting Whiz
358 posts since Jan 2012
Reputation Points: 57 [?]
Q&As Helped to Solve: 49 [?]
Skill Endorsements: 2 [?]
 
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.

Member Avatar
zeroliken
Nearly a Posting Virtuoso
1,222 posts since Nov 2011
Reputation Points: 79 [?]
Q&As Helped to Solve: 216 [?]
Skill Endorsements: 15 [?]
 
1
 

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

Member Avatar
cutterpillow20
Newbie Poster
9 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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...

Member Avatar
cutterpillow20
Newbie Poster
9 posts since Sep 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article