character-arrays Questions

10

Solved

Is there a nice way to iterate on the characters of a string? I'd like to be able to do foreach, array_map, array_walk, array_filter etc. on the characters of a string. Type casting/juggling didnt...
Reamonn asked 5/1, 2011 at 5:14

4

Solved

I have a character array and I'm trying to figure out if it matches a string literal, for example: char value[] = "yes"; if(value == "yes") { // code block } else { // code block } This result...
Geo asked 28/10, 2009 at 19:6

3

Solved

Given the next code example, I'm unable to free the parameter const char* expression: // removes whitespace from a characterarray char* removewhitespace(const char* expression, int length) { int ...
Merely asked 15/6, 2012 at 19:50

3

I'm writing a program for school that asks to read text from a file, capitalizes everything, and removes the punctuation and spaces. The file "Congress.txt" contains (Congress shall make no law ...
Squirt asked 19/4, 2015 at 21:44

4

Solved

I am attempting to write a function that will remove all characters from an array, except for '+', '-', '*', '/', and numbers. This is the code I came up with: void eliminateJunk(char string[MAX])...
Rosinweed asked 8/4, 2015 at 10:0

1

Solved

I have a block of code where I'm trying to grab an expression inside of parentheses and then use it. At the point where the below code begins, I am in the middle of iterating through a character ar...
Cung asked 23/2, 2015 at 3:20

5

Solved

My C is a little more than rusty at the moment, so I'm failing to create something I think should be pretty basic. Allow me to refer to character arrays as strings for this post. It will make thin...
Inculpable asked 18/4, 2013 at 19:50

7

Solved

I sit around and think about whether or not I should be using const char* or const std::string& pretty often when I'm designing class interfaces and when it comes down to it, I often feel like ...
Sapienza asked 30/4, 2014 at 8:38

4

Solved

I'm working through K&R second edition, chapter 5. On page 87, pointers to character arrays are introduced as: char *pmessage; pmessage = "Now is the time"; How does one know that pmessage ...
Gragg asked 14/3, 2014 at 11:59

2

Solved

I'm having to write a subroutine that can be called both by C and by Fortran. This subroutine takes a file name as one of its arguments. I know that to interoperate nicely with C, the ISO C binding...
Estellestella asked 13/3, 2014 at 17:55

2

Solved

Given a single string value in a MATLAB character array: ['12 N'] How can I repeat this value X times in a new character array? For example: X = 5 ['12 N'; '12 N'; '12 N'; '12 N'; '12 N']
Nuisance asked 7/3, 2014 at 18:53

2

Solved

I know that we have to use a null character to terminate a string array like this: char str[5] = { 'A','N','S','\0' }; But I just wanted to know why is it essential to use a null character...
Irrupt asked 8/6, 2013 at 2:30

2

Solved

Here's what the Beez C guide (LINK) tells about the %[] format specifier: It allows you to specify a set of characters to be stored away (likely in an array of chars). Conversion stops when a char...
Flourish asked 9/5, 2013 at 4:46

4

Solved

Now lets see this small program char s[20]="One"; strcat(s,"Two"); cout<<s<<endl; Here at first s has the value "One" and for visual representation this is the value of s: O - n - e...
Matheson asked 6/8, 2012 at 19:29

4

Solved

I have the following test application: #include <stdlib.h> #include <string.h> #include <stdio.h> int main(void){ char buf[512]; buf[0]= 0x1; buf[1]= 0x2; char *temp1 = &amp...
Danit asked 6/10, 2011 at 2:45

2

Solved

I have a code in which the character array is populated by integers (converted to char arrays), and read by another function which reconverts it back to integers. I have used the following function...
Charr asked 11/6, 2011 at 18:55
1

© 2022 - 2024 — McMap. All rights reserved.