Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-10-2008, 04:33 PM
hybridalter hybridalter is offline
Newbie
 
Join Date: Apr 2008
Posts: 7
Rep Power: 0
hybridalter is on a distinguished road
Default Structures?

can someone give me an example or sample code implementing structures,
like say i want to print the elements of a structure and it has a matrix?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-11-2008, 12:58 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default Re: Structures?

What do you mean by it shall have a matrix? Shall the code include a multidimensional array of structures, or shall the structure include a multidimensional array?
Code:
typedef struct
{
    int integer;
    char character;
    char *string;
    float array[3][3];
} myStructure;

// ...

myStructure ms;
myStructure msa[2];

// Using ms
ms.integer = 1234;
ms.character = 'A';
ms.string = "ABC";
// You could use a loop for the following...
ms.array[0][0] = 1.0; 
ms.array[0][1] = 1.0;
// ...
ms.array[2][2] = 1.0;

// Using msa
msa[0].integer = 1234;
msa[1].integer = 1234;
msa[0].character = 'A';
msa[1].character = 'A';
msa[0].string = "ABC";
msa[1].string = "ABC";
// You could use a loop for the following...
msa[0].array[0][0] = 1.0; 
msa[0].array[0][0] = 1.0; 
msa[1].array[0][1] = 1.0;
msa[1].array[0][1] = 1.0; 
// ...
msa[0].array[2][2] = 1.0;
msa[1].array[2][2] = 1.0;
If you want to print the members, you simply use the same form as for assignment. You print structure_name.member_name
__________________
05-03-2007 - 11-13-2008
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-11-2008, 01:28 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,897
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Structures?

Maybe he means "matrix" as in game programming.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-12-2008, 07:28 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,478
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default Re: Structures?

Quote:
Originally Posted by Xav View Post
Maybe he means "matrix" as in game programming.
Or maybe he means "Matrix" as in the movie.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-13-2008, 07:58 AM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,897
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Structures?

Scary.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 04-15-2008, 04:06 PM
hybridalter hybridalter is offline
Newbie
 
Join Date: Apr 2008
Posts: 7
Rep Power: 0
hybridalter is on a distinguished road
Talking Re: Structures?

haha i meant the array of structures, thanks for the help void, i understand alot better now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-15-2008, 04:18 PM
Xav's Avatar   
Xav Xav is offline
Code Warrior
 
Join Date: Mar 2008
Location: On God's Planet
Posts: 9,897
Last Blog:
Web slideshow in JavaS...
Rep Power: 78
Xav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud ofXav has much to be proud of
Send a message via MSN to Xav
Default Re: Structures?

Glad to hear it.
__________________


Mr. Xav | Website | Forums | Blog
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between c and c++ Chinmoy C Tutorials 38 08-27-2008 04:10 AM
Array of structures problems esmeco C and C++ 1 03-28-2008 12:32 PM
Usage of array structures to increment letter instances of text Yuriy M C and C++ 2 09-13-2007 11:49 AM
NULL/0 distinction in associative structures opsyde C and C++ 1 08-04-2007 06:41 AM
C basics. justin1993 C and C++ 4 07-24-2007 08:56 AM


All times are GMT -5. The time now is 11:20 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 101%


Complete - Celebrate!

Ads