char

  • Scanning a single character in c 2019-03-22

    This question already has an answer here: Scanf skips every other while loop in C 10 answers I have used the following code snippet to read several values but the single character constant variable rating is not accepting any value. It doesn't execut

    Tags: scanf, char
  • Why is my char printing as a number instead of a character? 2018-11-15

    As per the Java ternary operator expression ? statement1 : statement2, if expression is true then statement1 will be executed, if expression is false then statement2 will be executed. But when I run: // some unnecessary codes not displaying char y =

    Tags: java, int, char
  • For a guaranteed single character, is it better to use `char` or `string`? 2018-06-30

    I have a variable that's guaranteed to be a single character (substr from a std::string). I strongly suspect that it's more efficient to use a char, i.e. char c = name.c_str()[offset]; instead of the more complicated (and costly) std::string c = name

    Tags: string, char
  • Add and print multiple char in C 2018-04-13

    I'm creating a Dice Game, where the user rolls 3 dice and gets some random outputs (up to integer 6). My next step is to add those 3 values obtained and get its sum. How do I achieve this? Any suggestion would be helpful. Here's my source code: //Rol

    Tags: int, scanf, char, add
  • C programming pass char to function var list 2018-04-07

    I need help with passing char to function's var list. Here is the code: #include <stdio.h> #include <stdlib.h> /* for the exit command */ #pragma warning (disable :4996) void AddCustomer(char phone, char firstname, char lastname, char creditca

    Tags: arrays, pointers, file io, char
  • C++ getline forces to close a console application with space 2018-03-29

    The explanation: Working with two input streams streams, both use getline() to capture the user input. The first getline() is called in the userStringPrompt() function: string userStringPrompt() { string userString; cout << "Enter a string: &qu

    Tags: string, char, c strings, getline
  • cpp char to float not working 2016-02-02

    I am trying to convert char* argv[] values into float as following: #include<iostream> using namespace std; int main(int argc, char *argv[]) { float num1; num1 = atof(argv[1]); return 0; } I even tried num1 = (float) (argv[1]). But not working. Plea

    Tags: floating point, char
  • char array string confusion 2015-03-01

    I'm in trouble and I cannot wrap my head around this myself.. // string::operator+= vs + #include <iostream> #include <string> using namespace std; int main () { unsigned char array[6]= { 'f','o','o','b','a','r' }; string name ("works and

    Tags: string, type conversion, char
  • How to cut or truncate lines from a text file in C 2015-03-01

    This question is an exact duplicate of: How can I perfectly truncate a string in c? 2 answers I am reading from a file of which each line is greater than 63 characters and I want the characters to be truncated at 63. However, it fails to truncate the

    Tags: string, arrays, truncate, char
  • How get int from hex with Objective-C? 2015-03-01

    I have char with hex value '\xa1', it's 161, and how I can get 161 in int value? This doesn't work for me: char a = '\xa1'; int b = a; And I have a uint8_t buffer[4], it reads bytes from NSInputStream, with hex value like this, how I can get array wi

    Tags: int, objective c, encoding, hex, char
  • In java, how to convert char class expressions to char array 2015-02-16

    Given a char class expressions, like "[A-Z][0-9]", is there a parser that can take this expression and return a char array that contains all the characters in the range? like: char[] result = RequiredServiceClass.parse ("[A-Z][0-9]abc"); So result wi

    Tags: regex, arrays, class, expression, char
  • How to copy a string to a two-dimensional array of char 2015-02-16

    my problem is that when copy another string from a file into a two-dimensional array of char gets an error: "Expression: string subscript out of range" It needs help, not programmed much advancement so please be as easy as possible explanation and so

    Tags: string, arrays, char, dimensional
  • C/C++ - Storing characters from file into a 2d char array 2014-12-29

    I'm trying to store characters who are letters from a file in a 2-D array, and after I finish with the last word on the first line , I want to go to the next line and do the same. (I presumed i have 4 lines in my text). Here is my code : void getPoem

    Tags: arrays, matrix, char
  • Outputting to console from Char Array 2014-12-18

    im creating a hangman game that has to use CHAR and not strings. I was wondering how i would choose a single random word form a Char array and display it to the console as a symbol e.g. ****** instead of the word. My current array; Thank you. char wo

    Tags: arrays, char
  • Why does that works in c++ char arays 2014-12-01

    This question already has an answer here: No out of bounds error 6 answers I have the next code: char arr[6] = "Hello"; strcpy(arr,"Hello mellow"); cout<<strlen(arr)<<", "<<arr<<endl; // 12, Hello mellow char arr1[] = "Hello";

    Tags: arrays, char
  • How do you use user input for characters in a calculation? 2014-11-24

    How can you take in a sign (*, +, or -) and use that in a calculation in java? Example: int n = 10; int f = 10; //sign is the user input for the character to be used in the calculation. /* Insert something along the lines of int r = f sign n; if sign

    Tags: java, user, input, char
  • Java: How do I know if char consist of a symbol? 2014-11-17

    I seldom used char and today while I am trying to code my project , I am stuck at some concept. In my node class public class Node { private char c; private int weight; private Node leftChild, rightChild; public Node(char a, int f) { c = a; freq = f;

    Tags: java, character, char
  • In a C function what's the difference between char and string? 2014-11-13

    I'm using a template from my teacher and at the beginning of the code is says: #include "lab8.h" void main(void) { int response; int count; string words[MAX_COUNT]; Later on in the function, a whole lot of words get put inside the words string. So I

    Tags: string, char
  • Program crash on file output c++ 2014-11-09

    My program crashes unexpectedly when I try and output my results to a .txt file. Basically, I want to store a list of students in a .txt file and retrieve them for later convenience. My program can store the values as variables, however the moment yo

    Tags: stream, char, ifstream
  • How to pass multiple string literals to function using an array (Without vectors) 2014-11-02

    Currently I have this class: class Menu { void setVars(const char*,const char*, const char*); const char *item1; const char *item2; const char *item3; Menu(const char *setItem1, const char *setItem2, const char *setItem3) { setVars(setItem1, setItem2

    Tags: arrays, pointers, char, const

Copyright (C) dskims.com, All Rights Reserved.

processed in 6.045 (s). 10 q(s)