Questions tagged [chars]

a datatype that can hold a character of the implementation’s character set.

208 questions
0
votes
1 answer

Writing a string repeater in C produces unwanted chars

I'm trying to get a custom string repeater to work in C. It works for some input, and in other cases, it appends unwanted characters. It seems to me malloc in some cases allocates too much memory, but I don't quite grasp…
Aphex
  • 408
  • 1
  • 5
  • 17
0
votes
3 answers

Storing Chars Into Strings in C++

So right now I have this code that generates random letters in set increments determined by user input. #include #include #include using namespace std; int sLength = 0; static const char alphanum[]…
Cistoran
  • 1,587
  • 15
  • 36
  • 54
0
votes
2 answers

Java - read file char by char and count number of lines

import java.util.*; import java.io.*; public class Doomday { public static void main (String args[]) throws FileNotFoundException { Scanner scan = new Scanner(new File(args[0])); //provide file name from outside int counter =0;…
mariatsamp
  • 49
  • 7
0
votes
1 answer

How do I only read in unique lines using command-line arguments?

Currently, my C program, alter.c, successfully creates a char array, a, from text files invoked using command-line arguments. However, I want to alter it so that instead of reading in every line, it will only read in lines that are not consecutive…
jtuntalan
  • 21
  • 4
0
votes
0 answers

c++ custom string class failed to output objects inside vector

I'm trying to implement custom String class and I'm failing at console output, I have the following code: class MyString { public: MyString() { _length = 0; _str = new char[0]; } MyString(const char* c_str) { …
user6552967
0
votes
6 answers

How to filter integers and copy them to a new array from a String

Having a string (any string). It may not contain numbers; How can I store the integers contained in that array into an ArrayList. Tried to public ArrayList toList() { String stringToList; ArrayList l = new ArrayList<>(); …
ismael oliva
  • 97
  • 1
  • 3
  • 11
0
votes
1 answer

Java - Extract relevant strings/chars from specific index in file

I want to extract relevant strings/chars from specific indexe in a txt file. I know how to read the text file line by line but i need help with extracting relevant strings from fixed positions of the line. lets say i have a txt file that has this…
Genesis
  • 55
  • 3
  • 13
0
votes
2 answers

Replace ) in Notepad++

How do I replace ) when it comes after 1, 2, or 3 digits (not chars, and without removing the digit(s) themselves)?
Markov
  • 45
  • 6
0
votes
2 answers

random chars in dynamic char array C

I need help with char array. I want to create a n-lenght array and initialize its values, but after malloc() function the array is longer then n*sizeof(char), and the content of array isnt only chars which I assign... In array is few random chars…
ARistich
  • 3
  • 3
0
votes
1 answer

Checking whether chars are uppercase or lowercase in c++

I'm a beginner to c++ and I'm stuck at the very beginning. The problem is simple: a letter is the input and the output should be "it's uppercase" or "it's lowercase", or simply "error" when it's not a letter. And that's where I got stuck. #include…
T jey
  • 23
  • 1
  • 4
0
votes
1 answer

Multiplication formula string - java

I'm trying to write a code that take a string : (7+5)*(6+9) and return the string : 7*6 + 7*9 + 5*6 + 5*9 my algorithm is to create 2 char arrays (for this example : 75,69) and run in O^2 loop in this 2 arrays and copy value from first array , *…
Michael26
  • 27
  • 7
0
votes
1 answer

C++ Switch statement and symbols

I'm currently using switch statements with c++, I worked through some examples and used an independent example to finish with. The example I chose was a currency converter from eur to gbp. In all cases, my code reverted to the default as if the…
0
votes
3 answers

should this example not alter the memory address rather than the value at that memory address?

In a book I am reading, C++ from scratch, on page 113 the writer creates a char array: myString[80]; then he uses a function that copies some charectars: strcpy(myString,"Hello there"); then he creates a pointer to the array: *p1 = myString; then…
0
votes
2 answers

Selecting Characters In String

I can grab every 2 chars from sum2.text in order (102030) i get 10,20,30 but my issue is, selecting exactly those numbers 10,20,30 in order my current code below outputs: msgbox(10) msgbox(20) msgbox(30) but wont select and replace those exact…
alan7811
  • 65
  • 1
  • 8
0
votes
2 answers

How to Print Only Distinct Characters in an Array

I am trying to print only the non-duplicate (distinct) characters in an array of characters. I am probably doing something elementary wrong. Can you explain and show me my mistake? This is my code: public class MyDistinctCharacters { public…
Vilkas
  • 1
  • 1