FAQ Database Discussion Community


C programming language :if statements are not working correctly with characters [duplicate]

c,if-statement,chars
This question already has an answer here: How do I properly compare strings in C? 3 answers I'm trying to make this program say good but it says okay instead though I made the variable value the same of the if test value #include <stdio.h> #include <stdlib.h> int main()...

Character digit not true when read from UTF-8 file

java,utf-8,filestream,chars
So im using a scanner to read a file. However i dont understand that if the file is a UTF-8 file, and the current line being read when iterating over the file, is containing a digit, the method Character.isDigit(line.charAt(0)) returns false. However if the file is not a UTF-8 file...

Trying to pass a string as an argument for a class but it is being recognized as an array of chars instead in C++

c++,arrays,string,constructor,chars
I am having problems initializing Warrior Objects in my main function The code for my Warrior Class is below class Warrior{ public: Warrior(const string& input_name, int& input_strength) :name(input_name), strength(input_strength) {}; string getname()const{ return name; }; int getstrength(){ return strength; }; void change_strength(int damg_taken){ strength -= damg_taken; }; private: string name;...

Python: Insert two sets of chars into a matrix

python,matrix,fill,chars
Working with the Playfair cipher. I have two sets of chars: a keyword and the rest of the alphabet without the characters within the keyword. Example (Due to the nature of the Playfair cipher, 'i' is not taken into account to work with 25 characters, good fit for a 5x5...

Trying to compare chars from matrix C

c,matrix,chars
I'm tryingto compare chars from a matrix, but it's not adding any values and i don't know why so here's my code: #include <stdio.h> #include <math.h> #include <assert.h> #include <limits.h> #include <string.h> #include <stdlib.h> #define MAX_LINES 1000 #define MAX_LINE_LENGTH 1000 //--------------------- //READING & WRITING //--------------------- char *ints_new(int n) { return...

Reading text file and breaking it by delimiters

c,arrays,chars
I am trying to read a text file with the following structure: Item 1 - 50, Item 2 - 400, Item 3 - 120, Item 4 - 15; and while looping over the file, I want to store the price and the item name in two strings. To make it...

Unicode characters in /bin/sh VS /bin/bash

bash,unicode,sh,chars
Please try: bash -c "printf '\u2744'" bash -c "echo -e '\u2744'" And so: sh -c "printf '\u2744'" sh -c "echo -e '\u2744'" Why in /bin/bash I can get that unicode character but not in bin/bash? How to print a unicode characer (for example ❄) in /bin/sh?...