C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 14th, 2013, 05:25 AM
anishh2003 anishh2003 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 anishh2003 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 56 sec
Reputation Power: 0
Initializing datatypes in another function

Hi All ,

I would like someone to guide me as to how to go about doing this . I would like to initialise all my dataypes in one function and call them from main . Is this a possiblity ?

Code:

void Initialize();

void Initialize()
{
 int t = 4 ;
 int time ;
 char name;
}

void main()
{
 Initialize();
 printf(" t = %d", t);
}  
 

Reply With Quote
  #2  
Old February 14th, 2013, 05:34 AM
dariyoosh's Avatar
dariyoosh dariyoosh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Location: Iran / France
Posts: 138 dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level)dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level)dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level)dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level)dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level)dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level)dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level)dariyoosh User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 9 h 8 m 33 sec
Reputation Power: 133
Hi,

Either

- you need to use global variables, initialized inside your function, which is not often recommended as there could be unexpected side effects leading to ambiguous situations when the program becomes larger in future

- Or an initializing function returning the initialized variables, but again the types must already have been declared globally.

Regards,
Dariyoosh

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Initializing datatypes in another function

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap