char-pointer Questions
5
I am new to C programming. and I know char * and char[] array are different. Yet, you can deduct the char[] to char * when it comes to a function param. So function declarations could be the same.
...
Prudi asked 14/5, 2022 at 0:7
2
Yesterday, someone showed me this code:
#include <stdio.h>
int main(void)
{
unsigned long foo = 506097522914230528;
for (int i = 0; i < sizeof(unsigned long); ++i)
printf("%u &quo...
Courson asked 16/2, 2021 at 14:21
1
I created a class called person with the public member function fill_data which takes two arguments as char array and int . I passed the arguments like this fill_data("tushar",30); but there ...
Separate asked 10/6, 2019 at 8:2
12
Solved
I have a char pointer which would be used to store a string. It is used later in the program.
I have declared and initialized like this:
char * p = NULL;
I am just wondering if this is good pra...
Prettypretty asked 2/11, 2009 at 10:19
1
Solved
Suppose I have a program like this:
#include <iostream>
#include <string>
#include <vector>
// Takes values and outputs a string vector.
std::vector<std::string> foo(const...
Flavine asked 11/2, 2019 at 11:19
2
Solved
I'm looking through my textbook and I'm a little confused about some of the code in there. In one part, they are performing pointer arithmetic in the following way:
void* bp;
...
bp = (void*)((char...
Noumenon asked 7/4, 2012 at 20:45
3
Solved
The following line of code produces a compiler warning with HP-UX's C++ compiler:
strcpy(var, "string")
Output:
error #2167: argument of type "unsigned char *"
is incompatible with parameter ...
Shontashoo asked 8/3, 2018 at 5:14
2
Solved
When doing pointer arithmetic with offsetof, is it well defined behavior to take the address of a struct, add the offset of a member to it, and then dereference that address to get to the underlyin...
Godesberg asked 2/10, 2017 at 10:52
6
Solved
I am really confused about the use of pointers on strings.
It feels like they obey different rules.
Consider the following code
char *ptr = "apple";// perfectly valid here not when declaring afte...
Hoof asked 5/9, 2017 at 14:9
5
Why does the following assignment not work? I would like a low-level explanation if possible. Also, here's the compiler error I get: incompatible types in assignment of 'char*' to 'char [20]'...
Sox asked 19/6, 2013 at 3:51
1
Solved
This is a question in reference to this question:
What does (char *)0 mean in C?
There the answers slightly deviated away from explaining what exactly the answer was, but the final answer mentioned...
Brinna asked 29/4, 2016 at 6:28
2
Let's consider following piece of code:
struct Blob {
double x, y, z;
} blob;
char* s = reinterpret_cast<char*>(&blob);
s[2] = 'A';
Assuming that sizeof(double) is 8, does this code ...
Feeble asked 19/1, 2016 at 14:51
2
Solved
This question is a bump of a question that had a comment here but was deleted as part of the bump.
For those of you who can't see deleted posts, the comment was on my use of const char*s instead o...
Psychopathist asked 17/3, 2015 at 12:30
2
Solved
I answered a question here: https://stackoverflow.com/a/28862668/2642059 Where I needed to use recurrence to step through a string. I wanted to use a const string& as my parameter on each funct...
Shufu asked 12/3, 2015 at 10:51
2
Solved
In trying to get my head around graphics programming using c++ and OpenGL3+ I have come across a slightly specialized understanding problem with the char type, the pointers to it and potential impl...
Moguel asked 3/1, 2015 at 20:33
2
I have an API function that expects a char*** parameter and want to pass a vector<std::string>.
Are there member functions of std::string that let me do that?
This way, I only get the char p...
Prosthodontics asked 29/12, 2014 at 11:12
3
Solved
I am trying to learn pointers in C, and have gone through the concepts. I came across this lab question, and tried to write a solution for it.
/* p1.c
Write a short C program that declares and in...
Slink asked 9/6, 2014 at 2:12
1
Solved
This is what I have so far:
I pass an object which has 2 fields: String and Integer, as a parameter
and I want to send information to process it in C part, which is not important at this point......
Ubald asked 10/12, 2013 at 17:29
3
Solved
I am fairly new to C++, although I do have some experience programming. I have built a Text class that uses a dynamic char* as it's main member. The class definition is below.
#include <iostrea...
Gaitskell asked 30/11, 2013 at 20:22
1
© 2022 - 2024 — McMap. All rights reserved.