Hi, im developing this program, and then i ran into some trouble "oooh
no!" hate to ask.. have search google and this page for something to
spilt things up in arrays or whatever can be used, spent my half day
trying to find a solution, but nothing :( then i agreed with my self
that i have to ask. So her's the question/problem.
Link to project: http://kawsper.dyndns.dk/~jmo/develo...jects/n0rdnat/
I have a data file called "data", it contains:
timer: 1928384938485
total: 119283
drink: 10.5
Then in my sourcecode i've made a piece of code that reads the "data"
file and prints it out through a string. Now what i want this program
to do, is to take the value of fx.. "timer: " which is "1928384938 485"
into a integer so i can do something with it :) Can someone suggets how
i can do this..?
btw. my english i not so good since im from denmark :D
Thanks for help, if something ;) 4 2640
jm0 sade: Hi, im developing this program, and then i ran into some trouble "oooh no!" hate to ask.. have search google and this page for something to spilt things up in arrays or whatever can be used, spent my half day trying to find a solution, but nothing :( then i agreed with my self that i have to ask. So her's the question/problem.
Link to project: http://kawsper.dyndns.dk/~jmo/develo...jects/n0rdnat/
I have a data file called "data", it contains:
timer: 1928384938485 total: 119283 drink: 10.5
Then in my sourcecode i've made a piece of code that reads the "data" file and prints it out through a string. Now what i want this program to do, is to take the value of fx.. "timer: " which is "1928384938 485" into a integer so i can do something with it :) Can someone suggets how i can do this..?
It's basic math:
"1928384938 485"
5 * 1 +
8 * 10 +
4 * 100 +
8 * 1000 +
3 * 10000 +
9 * 100000 +
4 * 1000000 +
8 * 10000000 +
3 * 100000000 +
8 * 1000000000 +
2 * 10000000000 +
9 * 100000000000 +
1 * 1000000000000 = 1928384938485
Of course there are function like 'strtol' that can do it for you,
but with a large number like that you might want to worry about
overflow and alternative datatypes for representation, unless you're
on a 64 bit system.
--
TB @ SWEDEN
"jm0" <je************ ***@gmail.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Hi, im developing this program, and then i ran into some trouble "oooh no!" hate to ask.. have search google and this page for something to spilt things up in arrays or whatever can be used, spent my half day trying to find a solution, but nothing :( then i agreed with my self that i have to ask. So her's the question/problem.
Link to project: http://kawsper.dyndns.dk/~jmo/develo...jects/n0rdnat/
I have a data file called "data", it contains:
timer: 1928384938485 total: 119283 drink: 10.5
Then in my sourcecode i've made a piece of code that reads the "data" file and prints it out through a string. Now what i want this program to do, is to take the value of fx.. "timer: " which is "1928384938 485" into a integer so i can do something with it :) Can someone suggets how i can do this..?
btw. my english i not so good since im from denmark :D
Thanks for help, if something ;)
Normally, this would be rather trivial. Open ifstream, and then >> into the
int. The problem is, a 4 byte int's max value is:
4294967295
your timer value is:
1928384938485
this is quite a bit bigger than an int.
You're gonna need a 32 byte int to hold this. Does your system support one?
Otherwise it would just be:
unsigned int Timer;
unsigned int Total;
float Drink;
std::ifstream DataFile("data" );
if (DataFile.is_op en())
{
std::string KeyValue;
if ( DataFile >> KeyValue )
{
if ( KeyValue == "timer:" )
if ( DataFile >> Timer )
// success
else
// couldn't read value
else
// timer: expected, not found
}
}
DataFile.close( );
I close datafile even if it isn't open, and not only that but it is not even
strictly required to .close() datafile as when DataFile goes out of scope
the destructor will close it. It is just way I do it.
But, as stated, this won't quite work for you since your value in Timer
won't fit in a 16 bit unsigned int anyway.
Maybe you can load it into a std::string or something? What do you need to
do with it?
Jim Langston wrote: Normally, this would be rather trivial. Open ifstream, and then >> into the int. The problem is, a 4 byte int's max value is: 4294967295 your timer value is: 1928384938485
this is quite a bit bigger than an int.
You're gonna need a 32 byte int to hold this. Does your system support one?
Beg pardon? log(19283849384 85) < 41. So it needs 64 bits* (8 bytes),
not 256 bits (32 bytes).
Do I recall the following items correctly?
* sizeof(int) can be as small as 16
* sizeof(long) can be as small as 32
* long long is non-standard (or was it incorporated in '03?)
Luke
* Yes, technically only 41 bits are required, but I rarely acknowledge
the existence of numbers that are not powers of 2. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Lyn |
last post by:
I am trying to get my head around the concept of default, special or empty
values that appear in Access VBA, depending on data type. The Access Help
is not much (help), and the manual that I have is not much help here either.
Googling has given me a little help.
This is my current understanding -- I would appreciate any comments or
corrections...
"" -- this means an empty string when applied to String data type, and also
to Variant...
|
by: MLH |
last post by:
A97 Topic: If there is a way to preserve the values assigned to
global variables when an untrapped runtime error occurs? I don't
think there is, but I thought I'd ask.
During development, I'm constantly running tests on imperfect code.
On of the cumbersome jobs encountered is reassigning global vars
their values after a close encounter with an untrapped runtime error.
Rather than writing a procedure to simply reassign them all with a...
|
by: Russell |
last post by:
Hi there,
I'm currently creating a .NET Web Application and I have a question about
passing values from one screen to another. I previously used Session
variables in the code to store these values, however I can no longer use
this method because of my current website "Cloaking" the URL. (When site is
cloked, the session variables don't seem to work with frames)
Anyway, I was wondering if anyone could offer an alternative, I have tried...
|
by: Chris |
last post by:
Hi,
I have two froms (form1 and form2). I want to be able to pass values from
form 1 to form2 and be able to use those values leter in form2. This is my
code for form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Server.Transfer("form2.aspx", True)
End Sub
|
by: John Regan |
last post by:
Hello All
I am trying to find the owner of a file or folder on our network (Windows
2000 Server) using VB.Net and/or API. so I can search for Folders that don't
follow our company's specified folder structure and naming conventions and
then send a Net send message to those users telling them to rectify.
The information I want to get is when you select the file/folder and then:
Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
| |
by: Aaron |
last post by:
Complete code follows.
I am new to .NET programming (and programming in general) and I am having a
difficult time understanding how to fill a variable in one sub, and then
access it from another. I have tried declaring them as shared, public,
friend, etc and I always get an error stating that something is not valid
on a local variable declaration.
For example, in the following code for Sub DataGrid_Select, I have
CurrentID and...
|
by: Dennis D. |
last post by:
Hello:
I want a function to return three variables to the calling procedure:
Private Function CalcTimes(ByVal iAddDays as Integer, ByVal iAddHours as
Integer, ByVal iAddMins as Integer) As Array
Variable values are calculated in the function.
Calling procedure receives the values preferably into variables of the same
|
by: haelly |
last post by:
Write a program that prompts the user to enter three different integer values.If the values are not different, the program prints a message"equal values" and terminates(hint: use the return statement).If either of the values is negative,the progra prints"Negative input" and terminates.Otherwie, it prints the values that the user enters.
After that, the program compares the first integer and the second ineger and prints either "The first integer...
|
by: adamace5o |
last post by:
When i try to use post variables with php and mysql i can't get the insert into statement to accept varibles as values. If i use 'test' instead of $test it does work. I suspect it is something to do with the javascript im using but i can print the correct values so why am i unable to use them to enter data to a database? sorry i am new to all this
here is the updatedata.php file
<?php
session_start();
$host="localhost"; // Host...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |