Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,262 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,521 people online right now. Registration is fast and FREE... Join Now!




1 time int initialization

 
Reply to this topicStart new topic

1 time int initialization, how to::

ihatepikingnames
3 Nov, 2006 - 06:28 PM
Post #1

D.I.C Head
Group Icon

Joined: 31 Jul, 2006
Posts: 115


Dream Kudos: 75
My Contributions
refer to: http://code.dreamincode.net/snippet652.htm for source.

The first time this program is run a new save file is made. Is there anyway i could give the file a "0" value upon creation?
i dont just want to "if(fin==0){dont display "You have $$XXX";}"
Because i want people to know when there broke later on.

but it shows an adress which may be confusing to many people
the first time you fin. the data since its a new file.

EDIT: what about some kind of if exist(the file)nothing; else (makefile = 0)?


This post has been edited by ihatepikingnames: 3 Nov, 2006 - 06:32 PM
User is offlineProfile CardPM
+Quote Post

gregoryH
RE: 1 Time Int Initialization
4 Nov, 2006 - 12:13 AM
Post #2

D.I.C Regular
Group Icon

Joined: 4 Oct, 2006
Posts: 417


Dream Kudos: 50
My Contributions
QUOTE(ihatepikingnames @ 3 Nov, 2006 - 07:28 PM) *

refer to: http://code.dreamincode.net/snippet652.htm for source.

The first time this program is run a new save file is made. Is there anyway i could give the file a "0" value upon creation?
i dont just want to "if(fin==0){dont display "You have $$XXX";}"
Because i want people to know when there broke later on.

but it shows an adress which may be confusing to many people
the first time you fin. the data since its a new file.

EDIT: what about some kind of if exist(the file)nothing; else (makefile = 0)?

I am a little unsure of your question. I believe that you would like to be able to detect the prescence of the file.

Good news everyone... WIN32 API has such a function, goes by the name FindFirstFile I was looking for fileExists but that might be borland specific.
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: 1 Time Int Initialization
4 Nov, 2006 - 03:25 AM
Post #3

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,914



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
QUOTE
Good news everyone... WIN32 API has such a function, goes by the name FindFirstFile I was looking for fileExists but that might be borland specific.

Or we can even include dir.h and use the findfirst() and findnext() functions in the same way.

I disassembled the code to check if these functions use the Win32 API to do its job.
And it does, but only after lots and lots of error-checking conditions. Only after all checks have been passed, does it call the API Functions.

So I guess it's a better idea to use these functions than directly access the Win32 API.

User is offlineProfile CardPM
+Quote Post

ihatepikingnames
RE: 1 Time Int Initialization
4 Nov, 2006 - 08:39 AM
Post #4

D.I.C Head
Group Icon

Joined: 31 Jul, 2006
Posts: 115


Dream Kudos: 75
My Contributions
"If exist" is a DOS term mainly i think for .bat files... I just didnt know if there was a C term like that.

thanks for the help.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:10PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month