Search Results

Search found 23804 results on 953 pages for 'void pointer'.

Page 13/953 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • A Question about dereferencing pointer to incomplete type In C programming

    - by user552279
    Hi, can you explain this error for me? Blockquote /////////////////////////////// In my A.h file: struct TreeNode; struct TreeHead; typedef struct TreeNode * Node; typedef struct TreeHead * Head; /////////////////////////////// In my A.c file: struct TreeNode { char* theData; Node Left; Node Right; } ; struct TreeHead{ int counter; char type; Node Root; }; Head Initialisation() { Head treeHead; treeHead = malloc(sizeof (struct TreeHead)); treeHead-Root = malloc(sizeof (struct TreeNode)); return treeHead; } /////////////////////////////// In my Main.c file: Head head; Node tree; int choose =5; head = Initialisation(); (head-Root) = tree; //When compiling, this line has an error: error: dereferencing pointer to incomplete type Blockquote haed-Root will return a Node pointer, tree is also a Node pointer. So why error is dereferencing pointer to "incomplete" type?

    Read the article

  • Windows 8 black screen with mouse pointer after login

    - by Sagar Juneja
    I restarted my system today and after logging in, i could see see nothing but a black screen with mouse pointer. I can start task manager via alt+ctrl+del, Task manager and msconfig show fine but when i try to run 'explorer' nothing happens. In safe mode everything seems fine. I do not have any system restore points and repair options from the DVD show "this option is not available for the selected OS" I've also updated my graphic drivers. Didn't help

    Read the article

  • HREF link that targets nothing, does not want to use hash or void(0)

    - by Mattis
    I have a link that I want to be able to click to trigger a piece of jQuery code. Currently I have <a href="#" id="foo">Link</a> and $('#foo').click(function(){ // Do stuff }); which works well. But, I have always hated using hash in this way. The page flickers and the hash is added to the page url. One alternative is to use <a href="javascript:void(0);" id="foo">Link</a> but I also dislike seeing that piece of code in the browser status bar. It looks tacky. What I'd rather have is an explanatory javascript placeholder that does nothing, like <a href="javascript:zoom();" id="foo">Link</a> which actually works, but throws an ReferenceError in the javascript console since there are no such function. What's the minimum definition of a function that does nothing? Are there any other alternatives? Should I just skip the link and use something like <span id="foo" style="cursor:pointer;cursor:hand;">Link</span> instead?

    Read the article

  • Casting pointer to object to void * in C++

    - by JB
    I've been reading StackOverflow too much and started doubting all the code I've ever written, I keep thinking "Is that undefined behavour?" even in code that has been working for ages. So my question - Is it safe and well defined behavour to cast a pointer to an object (In this case abstract interface classes) to a void* and then later on cast them back to the original class and call method using them? I'm fully aware that the code that does this is probably awful. I wouldn't even consider writing it like this now (this is old code which I don't really want to change), so I'm not looking for a discussion of better ways to do this. I already know how to write it better if I ever did this again. But if it's actually broken to rely on this in C++ then I'll have to look at changing the code, if it's merely awful code then changing it won't be a priority. I would have had no doubts about something this simple a year or two ago but as my understanding of C++ increases I actually find I have more and more worries about code being safe under the standards even if it works perfectly well. Perhaps reading too much stack overflow is a bad thing for productivity sometimes :P

    Read the article

  • Consumed WCF service returns void although return type (& value) specified

    - by Abs
    I have a WCF service that I am attempting to connect to via a console application for testing (although will move to WPF for the final interface). I have generated the proxy, added the service reference to my project in visual studio and I can see all the methods I have created in my WCF interface: SupportStaffServiceClient client = new SupportStaffServiceClient("WSHttpBinding_ISupportStaffService"); client.myMethod(message); However when I call a method, which in the WCF interface is specified as returning a value, the method returns void in the console application. client.getMethod(message); The WCF service method is definitely returning a message, I'm just unsure as to why the client cannot "see" the return.

    Read the article

  • delete pointer to 2d array c ++

    - by user1848054
    i have this pointer to 2d array of Robot class Robot ***rob; and this is here the code for the constructor !! and the program works fine !!! but now i am trying to build a destructor to delete this pointer !! and it keeps on crashing the program !! my question is , how to delete this pointer to 2d array of robots ? RobotsWorld::RobotsWorld(int x , int y) { X=x;Y=y; // returns the limitation of the matrix rob = new Robot**[x]; for(int i = 0; i < x; i++) { rob[i] = new Robot*[y]; for(int j = 0; j < y; j++) { rob[i][j] = NULL; } } }

    Read the article

  • Memory leak using (void) alloc

    - by Rudiger
    I have seen a similar line of code floating about in Apples code: (void)[[URLRequest alloc] initializeRequestWithValues:postBody url:verifySession httpHeader:nil delegate:self]; URLRequest is my own custom class. I didn't write this and I think the guy that did just grabbed it from Apple's example. To me this should leak and when I test it I'm pretty sure it leaks 16 bytes. Would it? I know how to fix it if it does but wasn't sure as it was taken from Apple's code.

    Read the article

  • pointer reference type

    - by Codenotguru
    I am trying to write a function that takes a pointer argument, modifies what the pointer points to, and then returns the destination of the pointer as a reference. I am gettin the following error: cannot convert int***' toint*' in return| Code: #include <iostream> using namespace std; int* increment(int** i) { i++; return &i;} int main() { int a=24; int *p=&a; int *p2; p2=increment(&p); cout<<p2; } Thanks for helping!

    Read the article

  • Handling pointer while updating a key value in rpgle

    - by abhinav singh
    my code goes like this femp uf e k disk dvar1 s 5p 0 c *loval setll emp c read emp c dow not %eof(emp) C eval ecode = ecode + 10 c eval var1=ecode c update recemp c var1 setgt emp c read emp c enddo c eval *inlr=*on here is a file named emp with record format name recemp with ecode as the key ...now when i am reading the file and then updating the ecode without using setgt ..the pointer is not moving ahead it is updating the same ecode value many time ...now when i use set gt pointer picks the next record but it dint work when two ecode values are same ...else also it will not be working with descending key values...is there any solution so that i can set pointer regardless of the fact whether the values are same or ascending or descending .......thanks

    Read the article

  • java.lang.Void in C#?

    - by user313661
    Hi, I am currently working with .Net 2.0 and have an interface whose generic type is used to define a method's return type. Something like interface IExecutor<T> { T Execute() { ... } } My problem is that some classes that implement this interface do not really need to return anything. In Java you can use java.lang.Void for this purpose, but after quite a bit of searching I found no equivalent in C#. More generically, I also did not find a good way around this problem. I tried to find how people would do this with delegates, but found nothing either - which makes me believe that the problem is that I suck at searching :) So what's the best way to solve this? How would you do it? Thanks!

    Read the article

  • Does copy_from_user modify the user pointer?

    - by Michael
    Does the copy_from_user function, declared in uaccess.h, modify the (void __user *)from pointer? The pointer isn't declared as const in the function declaration, only the contents it points to. The reason I ask is that I want to use copy_from_user twice, with the second copy_from_user copying from the place where the first one finished. I was planning on doing something like this, is it guaranteed to work? //buf is a user pointer that is already defined copy_from_user(my_first_alloced_region, buf, some_size); //do stuff copy_from_user(my_second_alloced_region, buf + some_size, some_other_size); Thanks in advance.

    Read the article

  • Double pointer as Objective-C block parameter

    - by George WS
    Is it possible (and if so, safe) to create/use a block which takes a double pointer as an argument? For instance: - (void)methodWithBlock:(void (^)(NSError **error))block; Additional context, research, and questions: I'm using ARC. When I declare the method above and attempt to call it, XCode autocompletes my method invocation as follows: [self methodWithBlock:^(NSError *__autoreleasing *error) {}]; What does __autoreleasing mean here and why is it being added? I presume it has something to do with ARC. If this is possible and safe, can the pointer still be dereferenced in the block as it would be anywhere else? In general, what are the important differences between doing what I'm describing, and simply passing a double pointer as a method parameter (e.g. - (void)methodWithDoublePointer:(NSError **)error;)? What special considerations, if any, should be taken into account (again assuming this is possible at all)?

    Read the article

  • Malloc to a CGPoint Pointer throwing EXC_BAD_ACCESS when accessing

    - by kdbdallas
    I am trying to use a snippet of code from a Apple programming guide, and I am getting a EXC_BAD_ACCESS when trying to pass a pointer to a function, right after doing a malloc. (For Reference: iPhone Application Programming Guide: Event Handling - Listing 3-6) The code in question is really simple: CFMutableDictionaryRef touchBeginPoints; UITouch *touch; .... CGPoint *point = (CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch); if (point == NULL) { point = (CGPoint *)malloc(sizeof(CGPoint)); CFDictionarySetValue(touchBeginPoints, touch, point); } Now when the program goes into the if statement it assigns the 'output' of malloc into the point variable/pointer. Then when it tries to pass point into the CFDictionarySetValue function it crashes the application with: Program received signal: “EXC_BAD_ACCESS”. Someone suggested not doing the malloc and pass the point var/pointer as: &point, however that still gave me a EXC_BAD_ACCESS. What I am (and it looks like Apple) doing wrong??? Thanks in advance.

    Read the article

  • Convert void* representation of a dword to wstring

    - by graham.reeds
    I am having dumb monday so my apologies for posting such a newbie-like question. I am using CRegKey.QueryValue to return a dword value from the registry. QueryValue writes the value into void* pData and the length into ULONG* pnBytes. Now there is a way of getting it from pData into a wstring probably via stringstream. The closest I came was getting the result as a hex string. I was about to work on converting the hex representation to a dword and then from there to a wstring when I decided that was just dumb and ask on here instead of wasting another hour of my life on the problem.

    Read the article

  • Add C pointer to NSMutableArray

    - by Georges Oates Larsen
    I am writing an Objective-C program that deals with low level image memory. I am using ANSI-C structs for my data storage -- Full blown objects seem overkill seeing as the data I am storing is 100% data, with no methods to operate on that data. Specifically, I am writing a customizable posterization algorithm which relies on an array of colors -- This is where things get tricky. I am storing my colors as structs of three floats, and an integer flag (related to the posterization algorithm specifically). Everyhting is going well, except for one thing... [actual question] I can't figure out how to add pointers to an NSMutableArray! I know how to add an object, but adding a pointer to a struct seems to be more difficult -- I do not want NSMutableArray dereferencing my pointer and treating the struct as some sort of strange object. I want NSMutableArray to add the pointer its self to its collection. How do I go about doing this? Thanks in advance, G

    Read the article

  • NSView -(void)keyDown in console program

    - by Jonas Byström
    I'm not getting the -(void)keyDown callback on my inherited NSOpenGLView (note that mouseMoved does not work either though I do setAcceptsMouseMovedEvents:YES, but that is not an issue yet). It implements - (BOOL)acceptsFirstResponder { return YES; } but still no luck. My knowledgeable friend implied that it might have something to do with that the application is still a console application and not a bundled .app (I'm currently porting it). If so: is there some way to circumvent? Could the cause be something else? When I terminate my console application, I frequently see all my keypresses go to stdout so it does seem reasonable...

    Read the article

  • Pointer-based binary heap implementation

    - by Derek Chiang
    Is it even possible to implement a binary heap using pointers rather than an array? I have searched around the internet (including SO) and no answer can be found. The main problem here is that, how do you keep track of the last pointer? When you insert X into the heap, you place X at the last pointer and then bubble it up. Now, where does the last pointer point to? And also, what happens when you want to remove the root? You exchange the root with the last element, and then bubble the new root down. Now, how do you know what's the new "last element" that you need when you remove root again?

    Read the article

  • rewrite a function using only pointer increment/decrement

    - by Richard Nguyen
    can anyone help me rewrite the function i wrote below using only points and pointer increment/decrement? I dont have much experience with pointer so I dont know what to do. void reverse(char * s) { int i, l = strlen(s); char c; for(i = 0; i < (l >> 1); i++) { c = s[i]; s[i] = s[l - i - 1]; s[l - i - 1] = c; } } do not use pointer arithmetic or array notation. any help or hint on how to rewrite the function above is appriciated. Thanks!

    Read the article

  • Returning new base class when the parent class shared pointer is the return type

    - by Ben Dol
    Can you have a parent class shared pointer return type of a function and then return a new child class without it being a shared pointer? I'm not sure how shared pointers work in these situations, do they act like a regular pointer? Here is my example: BaseEventPtr Actions::getEvent(const std::string& nodeName) { if(asLowerCaseString(nodeName) == "action") return new ActionEvent(&m_interface); return nullptr; } ActionEvent is the subclass of BaseEvent in this situation. Cheers!

    Read the article

  • C pointer array scope and function calls

    - by juvenis
    I have this situation: { float foo[10]; for (int i = 0; i < 10; i++) { foo[i] = 1.0f; } object.function1(foo); // stores the float pointer to a const void* member of object } object.function2(); // uses the stored void pointer Are the contents of the float pointer unknown in the second function call? It seems that I get weird results when I run my program. But if I declare the float foo[10] to be const and initialize it in the declaration, I get correct results. Why is this happening?

    Read the article

  • Alternatives to C++ Reference/Pointer Syntax

    - by Jon Purdy
    What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right reading order, such as &*char/ref ptr char? I'm working on a little language project, and legibility is one of my key concerns. It seems to me that this is one of those questions to which it's easy for a person but hard for a search engine to provide an answer. Thanks in advance!

    Read the article

  • Passing a pointer to a function that doesn't match the requirements of the formal parameter

    - by Andreas Grech
    int valid (int x, int y) { return x + y; } int invalid (int x) { return x; } int func (int *f (int, int), int x, int y) { //f is a pointer to a function taking 2 ints and returning an int return f(x, y); } int main () { int val = func(valid, 1, 2), inval = func(invalid, 1, 2); // <- 'invalid' does not match the contract printf("Valid: %d\n", val); printf("Invalid: %d\n", inval); /* Output: * Valid: 3 * Invalid: 1 */ } At the line inval = func(invalid, 1, 2);, why am I not getting a compiler error? If func expects a pointer to a function taking 2 ints and I pass a pointer to a function that takes a single int, why isn't the compiler complaining? Also, since this is happening, what happens to the second parameter y in the invalid function?

    Read the article

  • Alternates to C++ Reference/Pointer Syntax

    - by Jon Purdy
    What languages other than C and C++ have explicit reference and pointer type qualifiers? People seem to be easily confused by the right-to-left reading order of types, where char*& is "a reference to a pointer to a character", or a "character-pointer reference"; do any languages with explicit references make use of a left-to-right reading order, such as &*char/ref ptr char? I'm working on a little language project, and legibility is one of my key concerns. It seems to me that this is one of those questions to which it's easy for a person but hard for a search engine to provide an answer. Thanks in advance!

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >