# JavaScript : How to Calculate the Check Digit according to ISO 6346

Learn how to calculate the check digit according to ISO 6346 for shipping containers. Prevent errors in tracking and documentation with this simple algorithm.… Read More JavaScript : How to Calculate the Check Digit according to ISO 6346

# If the string contains an odd number of characters, how to add a ( _ ) character after the last character

How to add a character(_) after the last character? def split_string(string: str) -> list: n = 2 list1 = [string[i: i + n] for i in range(0, len(string), n)] return list1 print(split_string("123456")) # ["12", "34", "56"] print(split_string("ab cd ef")) # ["ab", " c", "d ", "ef"] print(split_string("abc")) # ["ab", "c_"] print(split_string(" ")) # [" _"]… Read More If the string contains an odd number of characters, how to add a ( _ ) character after the last character

# How to move the first letters in a word forward by a certain amount, Java

I’m new to coding, and need some help completing an assignment. It specifies that we need to take strings from a file, and shift the letters forward a certain amount. This is the part I’m struggling with: If a word has n letters, where n is an odd number, move the first (n+1)/2 letters to… Read More How to move the first letters in a word forward by a certain amount, Java

# C# Setting each character in a string to an asterisk (*) if a user has selected "Hidden" function

learning C# at the moment. Just wondering if it’s possible to set all the characters in a string to an asterisk symbol if a user has selected to hide the visibility of a password. Here is what I have so far: private string Password { get; set; } public bool Hidden { get; private set;… Read More C# Setting each character in a string to an asterisk (*) if a user has selected "Hidden" function

# comparing a string variable to an explicit char* value in C++

I don’t understand why this code compiles and runs: std::string s; std::cin >> s; // if (s == "done") { // version 1 if ("done" == s) { // version 2 std::cout << "We’re done here" << std::endl; } Version 1 works as I would expect. The compiler sees that s is a std::string, and… Read More comparing a string variable to an explicit char* value in C++

# How to delete string array from a struct in c

I wonder how to delete string array from a structure. For example I have a structure and an array defined this way: struct dataofcall { char day[25]; char country[25]; char startofthecall[6]; char endofthecall[6]; }; dataofcall call[MAX]; Then I ask user to input a number of calls that he wants to enter: for example: 3. Then… Read More How to delete string array from a struct in c

# How can I filter Integers from a String without filtering all Integers from that String?

I know the function: numbers xs = filter (\x -> x `elem` [0..9]) xs Example: numbers "123Text321" -> 123321 I don’t want to filter all the integers from the String, only the first set ("123"). What would a function need that only takes the first Integers from a string it sees and as soon as… Read More How can I filter Integers from a String without filtering all Integers from that String?

# Output issue while printing array of char

When I print the the element of the array of char the index in [5] & [6] are not correct in the output. package id_code; import java.util.Scanner; public class Main { public static void main(String[] args) { // creating input Scanner input = new Scanner(System.in); System.out.println("Enter your Id: "); long id = input.nextLong(); // convert… Read More Output issue while printing array of char

# C++, getting gibberish from const unisgned char array

I am trying to write a program with a simple login interface for school in C++. I am new and still learning but I am getting a strange error with the following snippet of code. Inside the loop it outputs the username,password and name just as intended but if I try to access the array… Read More C++, getting gibberish from const unisgned char array