LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2010, 01:14 PM   #1
gothrog
Member
 
Registered: Jun 2004
Distribution: Yellow Dog, Fedora, RedHat, Centos, Ubuntu, Suse Linux
Posts: 106

Rep: Reputation: 15
istringstream to long


All,

I'm getting kind of annoyed with this. I'm trying to convert an 8 digit string into a long. The code compiles, but I'm getting only 1 digit placed into the long.

I want the whole thing, can anyone tell me what I doing wrong?

Code:
            string strSubTmp = strCheck.substr(4,8);
            cout << "Time as string:  "  << strSubTmp << endl;

            istringstream isTmp(strSubTmp,istringstream::in);
            long lTmpTime;
            isTmp >> lTmpTime;
            cout << "lTmpTime=" << lTmpTime << endl;

Last edited by gothrog; 12-15-2010 at 04:21 PM.
 
Old 12-15-2010, 10:14 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Thanx for the code snippet...
... but could you give us a sample "strCheck", and the corresponding output from "cout 'TmpTime"?
 
1 members found this post helpful.
Old 12-16-2010, 10:23 AM   #3
gothrog
Member
 
Registered: Jun 2004
Distribution: Yellow Dog, Fedora, RedHat, Centos, Ubuntu, Suse Linux
Posts: 106

Original Poster
Rep: Reputation: 15
My apologize. The value is in hex coming in. I'm not sure how I missed something so simple.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C double to unsigned long long Conversion with mingw32 random0 Programming 1 12-15-2010 09:53 AM
LXer: This week at LWN: Long discussions about long names LXer Syndicated Linux News 0 05-19-2009 10:50 PM
Long standing USB problem with XP & Linux...long cbjhawks Linux - Hardware 4 02-23-2009 08:32 AM
long filename & long directory tree slack66 Slackware 1 09-20-2006 09:56 AM
istringstream??? danxl Programming 6 10-16-2003 08:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration