[Solved] How can I double a time value in C++ [closed]

Use ONE of the file-handling routines in C++ or C. Mixing FILE and ifstream is certain to cause problems. ifstream input; input.open(“time.in”); input>> hrs; input.get(); … should do the trick. If you want to be picky: if (input.get() != ‘:’) … complain about bad input … 0 solved How can I double a time value … Read more

[Solved] How to split a string by white spaces in C# [closed]

The data is fixed width columns so use following : using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Data; namespace ConsoleApplication1 { class Program { const string FILENAME = @”c:\temp\test.txt”; static void Main(string[] args) { FIX_WIDTH fixWidth = new FIX_WIDTH(FILENAME); } } public class FIX_WIDTH { int[] Start_Position = { 0, 55, … Read more

[Solved] Built in function to compare strings in C++?

You could use std::string::compare() which provides the same functionality as strcmp(). std::string name1 = “John”; std::string name2 = “Micheal”; int result = name1.compare(name2); Would roughly be the same as: const char* name1 = “John”; const char* name2 = “Micheal”; int result = std::strcmp(name1, name2); solved Built in function to compare strings in C++?

[Solved] How numbers are stored? [closed]

You have got the math totally wrong. Here’s how it really is since each bit can only take on either of two states only(1 and 0) , n bits as a whole can represents 2^n different quantities not numbers. When dealing with integers a standard short integer size of 2 bytes can represent 2^n – … Read more

[Solved] Split text file every 120,000 Lines?

Just another way using Enumerable.GroupBy and “integer division groups”: int batchSize = 120000; var fileGroups = File.ReadLines(path) .Select((line, index) => new { line, index }) .GroupBy(x => x.index / batchSize) .Select((group, index) => new { Path = Path.Combine(dir, string.Format(“FileName_{0}.txt”, index + 1)), Lines = group.Select(x => x.line) }); foreach (var file in fileGroups) File.WriteAllLines(file.Path, file.Lines); … Read more

[Solved] C++ String subcript out of range issue

You need to initialise your variables correctly: int firstLength = str1.length(); int secondLength = str2.length(); You’re also determining that one string is bigger than another, then proceeding to access elements in the shorter string according to the length of the longer one, which is giving you the subscript out of range error. You need to … Read more

[Solved] Running a Search Array

First you might change your if condition because you already test one time your searchArray == arr[i] if (searchArray == arr[i]) { cout << “Found value ” << searchArray << ” at index ” << i << “, taking ” << counter << ” checks !”; if (counter == 1) { cout << “We ran … Read more

[Solved] c# Assert.AreEqual not workng

https://msdn.microsoft.com/en-us/library/ms243458.aspx The third parameter in Assert.AreEqual(double, double, double) specifies the degree of accuracy you want for equality. Your code asks “is 2 within 2 of 1” which it certainly is. 5 solved c# Assert.AreEqual not workng