Search Results

Search found 17788 results on 712 pages for 'last'.

Page 16/712 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • getline() sets failbit and skips last line

    - by Thanatos
    I'm using std::getline() to enumerate through the lines in a file, and it's mostly working. It's left me curious however - std::getline() is skipping the very last line in my file, but only if it's blank. Using this minimal example: #include <iostream> #include <string> int main() { std::string line; while(std::getline(std::cin, line)) std::cout << "Line: “" << line << "”\n"; return 0; } If I feed it this: Line A Line B Line C I get those lines back at me. But this: Line A Line B Line C [* line is present but blank, ie, the file end is: "...B\nLine C\n" *] (I unfortunately can't have a blank line in SO's little code box thing...) So, first file has three lines ( ["Line A", "Line B", "Line C"] ), second file has four ( ["Line A", "Line B", "Line C", ""] ) This to me seems wrong - I have a four line file, and enumerating it with getline() leaves me with 3. What's really got me scratching my head is that this is exactly what the standard says it should do. (21.3.7.9) Even Python has similar behaviour (but it gives me the newlines too - C++ chops them off.) Is this some weird thing where C++ is expected lines to be terminated, and not separated by '\n', and I'm feeding it differently? Edit Clearly, I need to expand a bit here. I've met up with two philosophies of determining what a "line" in a file is: Lines are terminated by newlines - Dominant in systems such as Linux, and editors like vim. Possible to have a slightly "odd" file by not having a final '\n' (a "noeol" in vim). Impossible to have a blank line at the end of a file. Lines are separated by newlines - Dominant in just about every Windows editor I've ever come across. Every file is valid, and it's possible to have the last line be blank. Of course, YMMV as to what a newline is. I've always treated these as two completely different schools of thought. One earlier point I tried to make was to ask if the C++ standard was explicitly or merely implicitly following the first. (Curiously, where is Mac? terminated or separated?)

    Read the article

  • Sed script command truncating last line

    - by C. Ross
    I'm trying to remove the carriage returns (\r) from a file with the following command on AIX, but it's also removing my last line. Any suggestions? sed -e 's/\r\n/\n/g' ./excprule > ./excprule.tst Command sequence: dev1: sed -e 's/\r\n/\n/g' ./test_file ./test_file.tst dev1: diff test_file.tst test_file diff: 0653-827 Missing newline at the end of file test_file. 26a27 Trailer 25

    Read the article

  • Delete last line in txt file

    - by user3658127
    I wrote a foreach loop for my datagridview to write all rows to txt file. I have a problem as it adds 2 empty lines at the end, as 1 row is full of empty cells after adding/reading to datagrid view. Is there any way to omit the last line or delete it in txt? foreach (DataGridViewRow item in this.DB.Rows) { foreach (DataGridViewCell item2 in item.Cells) { if(item2.Value != null) filewrite.Write(item2.Value.ToString() + " "); } filewrite.WriteLine(""); }

    Read the article

  • Querying Last Entries group by DeviceId

    - by TTCG
    I have the database table logs as the following: I would like to extract the last entry of device, pollDate, status. For eg. deviceId, pollDate, status 1, 2010-95-06 10:53:28, 1 3, 2010-95-06 10:26:28, 1 I tried to run the following query but the distinct only selects the first records, not the latest SELECT DISTINCT deviceId, pollDate, status FROM logs GROUP By deviceId ORDER BY pollDate DESC So, could you please help me to extract the latest entries from the table? Thanks.

    Read the article

  • Get the last '/' or '\\' character in Python

    - by wowus
    If I have a string that looks like either ./A/B/c.d OR .\A\B\c.d How do I get just the "./A/B/" part? The direction of the slashes can be the same as they are passed. This problem kinda boils down to: How do I get the last of a specific character in a string? Basically, I want the path of a file without the file part of it.

    Read the article

  • finding last snapshot using boto

    - by shantanuo
    I have read the explanation about "describe_cluster_snapshots" from ... http://docs.pythonboto.org/en/latest/ref/redshift.html#boto.redshift.layer1.RedshiftConnection.create_cluster It has an option start_time and end_time but there is no way to sort it. How do I get the id of the latest snapshot using boto? Here is what I have tried but it does not seem to return the last snapshot. mysnap=conn.describe_cluster_snapshots() mysnapidentifier=mysnap['DescribeClusterSnapshotsResponse']['DescribeClusterSnapshotsResult']['Snapshots'][-1]['SnapshotIdentifier']

    Read the article

  • regular expression: extract last 2 characters

    - by dotnet-practitioner
    what is the best way to extract last 2 characters of a string using regular expression. For example, I want to extract state code from the following "A_IL" I want to extract IL as string.. please provide me C# code on how to get it.. string fullexpression = "A_IL"; string StateCode = some regular expression code.... thanks

    Read the article

  • combine 2 files with AWK based last colums

    - by mohammad reshad
    i have two files file1 ------------------------------- 1 a t p b 2 b c f a 3 d y u b 2 b c f a 2 u g t c 2 b j h c file2 -------------------------------- 1 a b 2 p c 3 n a 4 4 a i want combine these 2 files based last columns (column 5 of file1 and column 3 of file2) using awk result ---------------------------------------------- 1 a t p 1 a b 2 b c f 3 n a 2 b c f 4 4 a 3 d y u 1 a b 2 b c f 3 n a 2 b c f 4 4 a 2 u g t 2 p c 2 b j h 2 p c

    Read the article

  • SQL query: Last but one rank for user

    - by Derk
    My table structure looks like this: create table rankings ( id IDENTITY NOT NULL, user_id INT NOT NULL, game_poule_id INT NOT NULL, rank INT NOT NULL, insertDate DATETIME NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (game_poule_id) REFERENCES game_poules(id) ON DELETE CASCADE ); All old rankings of users per game are saved in this table. Now I want to have the last but one rank in the table for all users in a gamepoule. Has someone an idea how to achive this? Thanks

    Read the article

  • SQL - get the article title with the last comment date

    - by stacker
    I have articles table, article_comments. I want to get the value: last_modified_all of article. I need this value to be the great date of this two: the last_modified field of articles table. the last comment of article_comments last_modified column. Can someone help me? the structure is very simple, and you can guess is without problem.

    Read the article

  • Scrum meeting - dealing with the last question

    - by Wizzard
    In the 5/15 minute scrum meeting the 3 questions are asked. For the last question "what impediments are getting in your way" If a dev has problems - the xyz is going to have problems, this is likely going to draw the meeting out past 15 mins and could go into a hour long discussion. Is it the scrum masters job to help this user, is there something to stop this from going on more than 15 mins. Thoughts?

    Read the article

  • JQuery datepicker numberOfMonths: display current selection month last

    - by Paul
    Hi, I have a jquery datepicker with the numberOfMonths set to 3, currently when I click on the datepicker, the left side month is the current month. In most cases, the user is only going to be selecting a date prior to todays date so I would prefer the current month selected to be the last calendar i.e. March, April, May instead of the current implementation which is May, June, July. Greatly appreciate any help!

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >