[Solved] Issue with substr C++

As mentioned you can’t call substr() with a std::ifstream. What you probably meant was to take the parts from the line string read in a[i]= stoi(line.substr(4,2)); name[i]= line.substr(18,15); b[i]= stoi(line.substr(36,1)); Also note you’ll need to convert the substrings extracted to a number (instead of assigning them directly), hence I have added the stoi(). As also … Read more

[Solved] What is the process of this program written in Python?

It seems you are new to the world of programming. “sys.argv” is used to take Command Line Arguments. when you run as “python sample.py”, the variable sys.argv will be a single element list i.e. [“sample.py”] len(sys.argv) is 1 in this case The Expected Working of the program is: when you run as “python sample.py fileToRead.txt”, … Read more

[Solved] Python take a variable number of inputs? [closed]

amount = int(input(“Enter the amount of numbers that you have: “)) numbers = [] for i in range(amount): new = input(‘Enter number {}: ‘.format(i+1)) numbers.append(new) print(numbers) You should probably do some reading on loops in Python. 2 solved Python take a variable number of inputs? [closed]

[Solved] Analyzing strings in Python [closed]

You can count the length of the string using function len. str can contain all chars and letters. Try the following code: word = input(“Waiting for input: “) print(“Found “+str(len(word))+” letters!”) Testing it: Waiting for input: hello Found 5 letters! Testing it with numbers and other chars: Waiting for input: hello123!@# Found 11 letters! 2 … Read more

[Solved] Determine whether the input matches a specified format

Using a regex would work like this: import re regex = r’\d-\d{4}-\d{4}-\d’ preg = re.compile(regex) s1 = ‘9-9715-0210-0’ s2 = ‘997-150-210-0’ m1 = preg.match(s1) m2 = preg.match(s2) if m1: print(‘String s1 is valid’) else: print(‘String s1 is invalid’) if m2: print(‘String s2 is valid’) else: print(‘String s2 is invalid’) You can try the code at … Read more

[Solved] Taking input of a graph from text file in java till the end of file [closed]

a fast google search popped up this example https://www.mkyong.com/java8/java-8-stream-read-a-file-line-by-line/. for each line you get a String. split the string on whitespace: String[] lineArr = line.split(” “); Then use the 3 values in the array to create your stuff. easy peasy 🙂 0 solved Taking input of a graph from text file in java till the … Read more

[Solved] Specifying a path for a user defined file name [closed]

By default, the file gets created where ever the project files are for visual studio. because of $(ProjectDir) specified in Working Directory setting. consider: right-click on your project -> Properties -> configuration properties -> Debugging -> Working Directory always make sure you are changing/viewing the active configuration and active platform setting in that window by … Read more

[Solved] How can I get the new value of an input with jquery

Not sure if this is what you mean. But I’ve created a sample here where every click event it will get the value of the input fields. <input type=”text” id=”name”/> <input type=”text” id=”number”/> <button id=”getvalue”>Get value</button> Here’s the js $(document).ready( function(){ $(‘#getvalue’).click( function() { var nameVal = $(‘#name’).val(); var numVal = $(‘#number’).val(); if(nameVal == ” … Read more