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 12-21-2007, 04:56 PM
kenna kenna is offline
Learning Programmer
 
Join Date: Jul 2007
Posts: 30
Rep Power: 6
kenna is on a distinguished road
Default Struct notation

Hmm...is there really no way of modifying an entire struct, as opposed to having to use each element?

E.g.
Code:
struct {
    int a, b;
} foo;

...

foo = {2,4};
When you first declare a struct you can use it, but what about elsewhere in the code?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 12-23-2007, 01:55 PM
Freedom Doc Freedom Doc is offline
Newbie
 
Join Date: Dec 2007
Posts: 8
Rep Power: 0
Freedom Doc is on a distinguished road
Default

Quote:
Originally Posted by kenna View Post
Hmm...is there really no way of modifying an entire struct, as opposed to having to use each element?

E.g.
Code:
struct {
    int a, b;
} foo;

...

foo = {2,4};
When you first declare a struct you can use it, but what about elsewhere in the code?
Apparently you are referring to initialization, which can only be done at declaration time.

You CAN however do struct assignments, as with

struct Foo {
int a, b;
};

Foo Zero = {0,0}; //struct initialization

Foo Junk;

then later on,

Junk = Zero; //struct assignment
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
Struct in C and C++ dirkfirst C and C++ 9 03-05-2008 06:28 AM
[C]Functions Help! mtber C and C++ 1 12-05-2007 09:25 AM
Big O notation shinta General Programming 2 11-18-2007 11:36 AM
sizeof Struct Eagle_ C and C++ 2 11-18-2007 11:15 AM
'BigOh' Notation DansTransAM General Programming 3 09-14-2006 12:56 PM


All times are GMT -5. The time now is 11:29 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