logo
down
shadow

What's wrong with these pointer initialization


What's wrong with these pointer initialization

Content Index :

What's wrong with these pointer initialization
Tag : cpp , By : ravibits
Date : January 02 2021, 06:48 AM


Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

C pointer initialization and dereferencing, what's wrong here?


Tag : c , By : mckasty
Date : March 29 2020, 07:55 AM
I wish this help you You set the pointer to memory address 5, so that it points to whatever at address 5 might be. You probably wanted to make it point to an address where the value 5 is stored. For example:
int v = 5;    // Store the value 5 in a normal variable
int *n = &v;  // Make n contain the address of v, so that it points to the 
              // contents of v

warning: assignment makes integer from pointer without a cast. whats wrong?


Tag : development , By : Kyle
Date : March 29 2020, 07:55 AM
I hope this helps . strncpy returns a pointer which you are assigning to a char. (Actually, you are assigning it to an illegal address as r->label[NAMESIZE+1] is beyond the bounds of the array.)
It should be
struct rectangle *create_rectangle(struct point ul, struct point lr,
                                   char *label) {

    struct rectangle *r = malloc(sizeof(struct rectangle));


    r->upperleft=ul;
    r->lowerright=lr;
    strncpy(r->label,label,NAMESIZE);
    r->label[NAMESIZE] = '\0';

    return r;
}

Whats wrong with the Null pointer


Tag : cpp , By : chudq7
Date : March 29 2020, 07:55 AM
wish of those help You're passing the pointer by value, so inside the function you're actually assigning to a new pointer, not the original one.
Change the function prototype to void StrIn(char *&sp).

Whats wrong with this one? C++ Array Pointer


Tag : cpp , By : Priya
Date : March 29 2020, 07:55 AM
Does that help Looking at what you are asked to do I think you just have to determine the highest and lowest int in the array and point to. You sort the array thats slower.
I think it should look like that:
#include<iostream>
using namespace std;
int main()
{
    int kre_arr[10];
    int *low;
    int *high;

    cout<<"Enter 10 Integers: ";
    for (int i=0; i < 10; i++)
    {
        cin>>kre_arr[i];
    }

    //determine the lowest
    low=&kre_arr[0];
    for(int i=1;i<10;i++)
    {
       if(kre_arr[i] < *low)
       {
           low=&kre_arr[i];
       }
    }

    //determine the highest
    high=&kre_arr[0];
    for(int i=1;i<10;i++)
    {
       if(kre_arr[i] > *high)
       {
           high=&kre_arr[i];
       }
    }

    cout<<"lowest: "<<*low<<"\nhighest: "<<*high;
}

Initialization from incompatible pointer type [enabled by default] - whats wrong?


Tag : c , By : artifex
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Is it possible to roll a significantly faster version of modf
  • Updating pointer using signals and slots
  • How are classes more secure than structures?
  • finding "distance" between two pixel's colors
  • C++ Greatest Number Verification
  • Why does my token return NULL and how can I fix it?(c++)
  • C++ enforce conditions on inherited classes
  • what happened if an exception is not captured?
  • Redundant naming in C/C++ typedefs/structs
  • question about STL thread-safe and STL debugging
  • killing a separate thread having a socket
  • Returning the size of available virtual memory at run-time in C++
  • Parallel computing for integrals
  • How do I force my std::map to deallocate memory used?
  • C++ Templates: implicit conversion, no matching function for call to ctor
  • Adding python script to c++ project
  • C++ private pointer "leaking"?
  • Initializing Primitive Array to One Value
  • how is push_back implemented in STL vector?
  • C++ Profiling: KiFastSystemCallRet
  • Multiple rows with a single INSERT in SQLServer 2008
  • Use super class's address/pointer in initialization list
  • double fork using vfork
  • Convert char pointer (char*) to struct
  • Does anyone have good tips for using pc-lint?
  • C++ How fast is passing around objects?
  • template type's ctor arguments at instantiation time
  • Get list of windows in taskbar on Windows 7?
  • Curl connection options
  • Best cross-platform solution for network server?
  • simple c++ file opening issue
  • Switching from C++ (with a lot of STL use) to C for interpreter building
  • How can I access the JPEG image pixels as a 3D array like we do in MATLAB?
  • What wording in the C++ standard allows static_cast<non-void-type*>(malloc(N)); to work?
  • Avoid allocating in constructor or preserve simplicity (and RAII?)
  • Can C++ raise an error when std array initialization is too small?
  • Reference to end is ambiguous
  • Problem with basic usage of std::enable_if
  • How to print out a decimal number as octal number using setiosflags in C++
  • Open Visual Studio with solution and specific file and line
  • Enum value based on template type
  • Is there any way to swap nodes in std::list?
  • How to copy QString into wchar_t buffer
  • Make the compiler generate an empty default function for an std::function
  • Insert or push_back to end of a std::vector?
  • Best practice for const temporary types
  • Include CSV File in Complied Binary
  • Issue with binding non static function to callback
  • How can read from some files and write content of them with different form into files with same names
  • Why does auto deduce this variable as double and not float?
  • no instance of overloaded function "std::make_unique" matches the argument list, but works with unique_ptr con
  • How to see array size from a pointer in c++
  • Error taking address of temporary in Eclipse
  • Using an iterator to go through a vector and modify the contents
  • Are extern extern "C", and extern "C" extern, allowed?
  • Can't solve C2660 and C2065 Errors
  • C referencing C++ extern
  • How to write the definition of a derived class in c++?
  • Why when I include <cmath> I need to use the namespace std too?
  • How to assign a 32-bit unsigned integer to a bit field containing 32 bits
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com