Search Results

Search found 3592 results on 144 pages for 'pointer'.

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

  • Getting Null Pointer Exception while reading sqlite database

    - by user1597569
    I have to read values from SQLite database but getting null pointer exception when I execute private final String DB_NAME = "UserDb"; private final String TABLE_NAMES = "tbluser"; SQLiteDatabase sampleDB; Cursor c=null; c= sampleDB.rawQuery("SELECT * from " +TABLE_NAMES+" where did='"+deviceDec+"' ", null); Please suggest me why I am getting the exception because at one function it is running but in other it is not. and the deviceDec value also i am getting I have checked in Log

    Read the article

  • In a class with no virtual methods or superclass, is it safe to assume (address of first member vari

    - by Jeremy Friesner
    Hi all, I made a private API that assumes that the address of the first member-object in the class will be the same as the class's this-pointer... that way the member-object can trivially derive a pointer to the object that it is a member of, without having to store a pointer explicitly. Given that I am willing to make sure that the container class won't inherit from any superclass, won't have any virtual methods, and that the member-object that does this trick will be the first member object declared, will that assumption hold valid for any C++ compiler, or do I need to use the offsetof() operator (or similar) to guarantee correctness? To put it another way, the code below does what I expect under g++, but will it work everywhere? class MyContainer { public: MyContainer() {} ~MyContainer() {} // non-virtual dtor private: class MyContained { public: MyContained() {} ~MyContained() {} // Given that the only place Contained objects are declared is m_contained // (below), will this work as expected on any C++ compiler? MyContainer * GetPointerToMyContainer() { return reinterpret_cast<MyContainer *>(this); } }; MyContained m_contained; // MUST BE FIRST MEMBER ITEM DECLARED IN MyContainer int m_foo; // other member items may be declared after m_contained float m_bar; };

    Read the article

  • PHP - can a method return a pointer?

    - by Kerry
    I have a method in a class trying to return a pointer: <?php public function prepare( $query ) { // bla bla bla return &$this->statement; } ?> But it produces the following error: Parse error: syntax error, unexpected '&' in /home/realst34/public_html/s98_fw/classes/sql.php on line 246 This code, however, works: <?php public function prepare( $query ) { // bla bla bla $statement = &$this->statement; return $statement; } ?> Is this just the nature of PHP or am I doing something wrong?

    Read the article

  • Problem using void pointer as a function argument

    - by Nazgulled
    Hi, I can't understand this result... The code: void foo(void * key, size_t key_sz) { HashItem *item = malloc(sizeof(HashItem)); printf("[%d]\n", (int)key); ... item->key = malloc(key_sz); memcpy(item->key, key, key_sz); } void bar(int num) { foo(&num, sizeof(int)); } And I do this call: bar(900011009); But the printf() output is: [-1074593956] I really need key to be a void pointer, how can I fix this?

    Read the article

  • Difference between Singleton implemention using pointer and using static object

    - by Anon
    EDIT: Sorry my question was not clear, why do books/articles prefer implementation#1 over implementation#2? What is the actual advantage of using pointer in implementation of Singleton class vs using a static object? Why do most books prefer this class Singleton { private: static Singleton *p_inst; Singleton(); public: static Singleton * instance() { if (!p_inst) { p_inst = new Singleton(); } return p_inst; } }; over this class Singleton { public: static Singleton& Instance() { static Singleton inst; return inst; } protected: Singleton(); // Prevent construction Singleton(const Singleton&); // Prevent construction by copying Singleton& operator=(const Singleton&); // Prevent assignment ~Singleton(); // Prevent unwanted destruction };

    Read the article

  • Iphone build error - literal-pointer symbol(s) not found

    - by Nick
    Sorry I imagine I'm missing something basic here. Before I write up a bunch of details on the specifics of the class I'd appreciate a nudge or smack on the head about the meaning of this build error. I have a subclass of NSObject SiteAnnotation that should be conforming to the MKAnnotation protocol. It is #imported in the ViewController in question When I try to alloc/init: SiteAnnotation *thisAnnotation = [[SiteAnnotation alloc] init]; This is the build error which occurs: Link /build/Debug-iphonesimulator/testbed.app/testbed ".objc_class_name_SiteAnnotation", referenced from: literal-pointer@__OBJC@__cls_refs@SiteAnnotation in MapViewController.o Symbol(s) not found collect2: ld returned 1 exit status Any tips appreciated.

    Read the article

  • After minimizing app, on restore, windows pursues mouse pointer

    - by Nuno Silva
    Hi! I have an application in WPF C# where other than the purpose of what it's done, I customized the close and minimize buttons. The problem is that when I minimize, all is good, I cycle around all other apps, but, when I want to go back to the application, I click in the window in the taskbar, and the window pops up... But when it pops up, the window pursues the mouse pointer throughout the screen... The code i've implemented the the simplest it can be... private void Minimize_LeftMouseDown(object sender, MouseButtonEventArgs e) { this.WindowState = WindowState.Minimized; } Can you point me some directions? Thanks

    Read the article

  • Pointer argument to boost python

    - by piotr
    What's the best way to make a function that has pointer as argument work with boost python? I see there are many possibilities for return values in the docs, but I don't know how to do it with arguments. void Tesuto::testp(std::string* s) { if (!s) cout << " NULL s" << endl; else cout << s << endl; } >>> t.testp(None) NULL s >>> >>> s='test' >>> t.testp(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> Boost.Python.ArgumentError: Python argument types in Tesuto.testp(Tesuto, str) did not match C++ signature: testp(Tesuto {lvalue}, std::string*) >>>

    Read the article

  • Twitter integration with C#.NET applications - NULL Pointer Exception

    - by Kanini
    Trying to integrate Twitter with ASP.NET application (Code in C#). This is the code I have written for the first sign in to Twitter. When I debug the application, I do get the token response and the response redirect happens appropriately. However, if I host it on IIS and access it, I get a Null Pointer Exception. Why is that? //Retrieve consumerKey and consumerSecret var v_consumerKey = ConfigurationManager.AppSettings["consumerKey"]; var v_consumerSecret = ConfigurationManager.AppSettings["consumerSecret"]; //Check if user is a valid user if (Request.QueryString["oauth_token"] == null) { OAuthTokenResponse t_requestToken = OAuthUtility.GetRequestToken(v_consumerKey, v_consumerSecret); Response.Redirect("http://twitter.com/oauth/authorize?oauth_token=" + t_requestToken.Token); } else { string s_oAuthToken = Request.QueryString["oauth_token"].ToString(); var v_accessToken = OAuthUtility.GetAccessToken(v_consumerKey,v_consumerSecret,s_oAuthToken); }

    Read the article

  • c struct pointer issues

    - by clear2k
    I'm trying to cast a struct into another struct but I'm having incompatible pointer issues within the cast and the malloc under some_func (structs layout are the same) struct stu1 **some_func(struct stu1 *my_struct) { my_struct = (struct stu1 **)malloc(sizeof(struct stu1 *)*total_size); for(i=0;i<20;i++){ my_struct[i] = (struct stu1 *)malloc(sizeof(struct stu1)); printf("%s",my_struct[i++]->a); } } int main() { struct stu1 **my_struct; struct stu2 **my_struct2; struct stu3 **my_struct3; my_struct = some_func(my_struct); my_struct2 = (struct stu2**)some_func((struct stu1*)my_struct2); my_struct3 = (struct stu3**)some_func((struct stu1*)my_struct3); }

    Read the article

  • ctypes and pointer manipulation

    - by Chris
    I am dealing with image buffers, and I want to be able to access data a few lines into my image for analysis with a c library. I have created my 8-bit pixel buffer in Python using create_string_buffer. Is there a way to get a pointer to a location within that buffer without re-creating a new buffer? My goal is to analyze and change data within that buffer in chunks, without having to do a lot of buffer creation and data copying. In this case, ultimately, the C library is doing all the manipulation of the buffer, so I don't actually have to change values within the buffer using Python. I just need to give my C function access to data within the buffer.

    Read the article

  • Access violation of member of pointer object

    - by Martin Lauridsen
    So I am coding this client/server program. This code is from the client side. The client has an instance of an object mpqs_sieve *instance_; The reason I make it as a pointer is, that mpqs_sieve only has a constructor that takes 3 arguments, and I want to instantiate it at a later point in time. The client first gets some data from the server, and uses this to instantiate instance_. After this, it will request some more data, and upon receiving this (these are three coeffecients for a quadratic polynomial), it should set these in the instance_ object. However upon calling a member function of instance_, I get an access violation on one of the members of instance_ within that function call. I posted my code here: on pastebin, and I get the error on line 100. The call comes from line 71, and before that line 21. Any ideas to solve this? Thanks!

    Read the article

  • Purpose of dereferencing a pointer as a parameter in C.

    - by Leif Andersen
    I recently came along this line of code: CustomData_em_free_block(&em->vdata, &eve->data); And I thought, isn't: a->b just syntactic sugar for: (*a).b With that in mind, this line could be re-written as: CustomData_em_free_block(&(*em).vdata, &(*eve).data); If that's the case, what is the point of passing in &(*a), as a parameter, and not just a? It seems like the pointer equivalent of -(-a) is being passed in in, is there any logic for this? Thank you.

    Read the article

  • How to do pointer work with accessor methods in Objective-C

    - by Jasconius
    Basic problem statement: I have a very good reason for doing some pointer fanciness in an app where I need to pass a decimal by reference. So I have a class which stores many a decimal, so let's say is has a property as such: @property (nonatomic) double myDecimalValue; I want to pass it by reference to some other class. [someOtherObject sendMyDecimalByReference:&myDecimalValue]; But, a problem emerges! The way that actually has to be written (because it's a property) is [someOtherObject sendMyDecimalByReference:&decimalOrigin.myDecimalValue]; This fails to compile in objective-c I get around it by writing the following - (double *) myDecimalValueRef; [someOtherObject sendMyDecimalByReference:[decimalOrigin myDecimalValue]]; Except I have dozens of these decimals and I don't want to write that stupid wrapper function for every value. Is there a shorthand way to do this in Objective-C using just the Getter functions? Let's just assume I have a great reason for not using NSNumber. Thanks!

    Read the article

  • How to set the pointer to the current row in the Datagridview in C Sharp

    - by user286546
    I have a datagridview on the Windows Form in c#. I am updating and filling the table adapter on the cell event. The problem is that When I go to lower half of the datagrid which is not visible until I scroll down, as I click any cell, the table adapter is filled and updated and the pointerpoints to the very first row. Any suggestion on how to fix it. I have a ideas to record the top row of the datagridview that is visible and set the pointer to that row. But how to do it?

    Read the article

  • GLib Hash Table - Pointer

    - by Mike
    I'm trying to increment the value of some specific key if it was found. For some reason I keep getting the (pointer) address when I dump all keys:values from the hash table. Output a: 153654132 // should be 5 b: 1 c: 153654276 // should be 3 d: 1 e: 1 f: 153654420 // should be 3 int proc() { struct st stu; gpointer ok, ov; //... some non-related code here if(!g_hash_table_lookup_extended(ht, key, &ok, &ov)){ stu.my_int = g_malloc(sizeof(guint)); *(stu.my_int) = 0; g_hash_table_insert(table, g_strdup(key), GINT_TO_POINTER(1)); }else{ stu.my_int = g_malloc(sizeof(guint)); *(stu.my_int)++; g_hash_table_insert(table, g_strdup(key), stu.my_int); } } Any ideas will be appreciate it.

    Read the article

  • GLib Hash Table - Pointer

    - by Mike
    I'm trying to increment the value of some specific key if it was found. For some reason I keep getting the (pointer) address when I dump all keys:values from the hash table. Output a: 153654132 // should be 5 b: 1 c: 153654276 // should be 3 d: 1 e: 1 f: 153654420 // should be 3 int proc() { struct st stu; gpointer ok, ov; //... some non-related code here if(!g_hash_table_lookup_extended(table, key, &ok, &ov)){ stu.my_int = g_malloc(sizeof(guint)); *(stu.my_int) = 0; g_hash_table_insert(table, g_strdup(key), GINT_TO_POINTER(1)); }else{ stu.my_int = g_malloc(sizeof(guint)); *(stu.my_int)++; g_hash_table_insert(table, g_strdup(key), stu.my_int); } } Any ideas will be appreciate it.

    Read the article

  • Pointer initialization doubt

    - by Jestin Joy
    We could initialize a character pointer like this in C. char *c="test"; Where c points to the first character(t). But when I gave code like below. It gives segmentation fault. #include<stdio.h> #include<stdlib.h> main() { int *i=0; printf("%d",*i); } Also when I give #include<stdio.h> #include<stdlib.h> main() { int *i; i=(int *)malloc(2); printf("%d",*i); } It worked(gave output 0). When I gave malloc(0), it worked(gave output 0). Please tell what is happening

    Read the article

  • Array pointer arithmetic question

    - by Konrad
    Is there a way to figure out where in an array a pointer is? Lets say we have done this: int nNums[10] = {'11','51','23', ... }; // Some random sequence int* pInt = nNums[4]; // Some index in the sequence. ... pInt++; // Assuming we have lost track of the index by this stage. ... Is there a way to determine what element index in the array pInt is 'pointing' to without walking the array again?

    Read the article

  • Referring to this pointer in a static assert?

    - by Tyson Jacobs
    Is it possible to write a static assert referring to the 'this' pointer? I do not have c++11 available, and BOOST_STATIC_ASSERT doesn't work. struct blah { void func() {BOOST_STATIC_ASSERT(sizeof(*this));} }; Produces: error C2355: 'this' : can only be referenced inside non-static member functions error C2027: use of undefined type 'boost::STATIC_ASSERTION_FAILURE' In MSVC 2008. Motivation: #define CLASS_USES_SMALL_POOL() \ void __small_pool_check() {BOOST_STATIC_ASSERT(sizeof(*this) < SMALL_MALLOC_SIZE;} \ void* operator new(size_t) {return SmallMalloc();} \ void operator delete(void* p) {SmallFree(p);}

    Read the article

  • Heap corruption detected error when attempting to free pointer

    - by AndyGeek
    Hi, I'm pretty new to C++ and have run into a problem which I have not been able to solve. I'm trying to convert a System::String to a wchar_t pointer that I can keep for longer than the scope of the function. Once I'm finished with it, I want to clean it up properly. Here is my code: static wchar_t* g_msg; int TestConvert() { pin_ptr<const wchar_t> wchptr = PtrToStringChars("Test"); g_msg = (wchar_t*)realloc(g_msg, wcslen(wchptr) + 1); wcscpy(g_msg, wchptr); free (g_msg); // Will be called from a different method } When the free is called, I'm getting "HEAP CORRUPTION DETECTED: after Normal block (#137) at 0x02198F90." Why would I be getting this error? Andrew L

    Read the article

  • Paypal - DoExpressCheckoutPayment null pointer

    - by user969894
    String nvpstr = "&TOKEN=" + token + "&PAYERID=" + payerID + "&PAYMENTREQUEST_0_PAYMENTACTION=" + paymentType + "&PAYMENTREQUEST_0_AMT=" + finalPaymentAmount + "&PAYMENTREQUEST_0_CURRENCYCODE=" + currencyCodeType + "&IPADDRESS=" + serverName; Having done an earlier call to SetExpressCheckout, I had to change a few parameter names because Paypal had changed it in the documentation but not in the code from the integration wizard. Now for DoExpressCheckoutPayment I've modified a few but I get a null pointer at strAck: HashMap nvp = httpcall("DoExpressCheckoutPayment", nvpstr); String strAck = nvp.get("ACK").toString(); if (strAck.equalsIgnoreCase("Success")) { return nvp; } Not sure what is wrong, any suggestions for debugging this or possible solutions?

    Read the article

  • C++ smart pointer for a non-object type?

    - by Brian
    Hi, I'm trying to use smart pointers such as auto_ptr, shared_ptr. However, I don't know how to use it in this situation. CvMemStorage *storage = cvCreateMemStorage(); ... use the pointer ... cvReleaseMemStorage(&storage); I'm not sure, but I think that the storage variable is just a malloc'ed memory, not a C++ class object. Is there a way to use the smart pointers for the storage variable? Thank you.

    Read the article

  • How to handle JPA annotations for a pointer to a generic interface

    - by HDave
    I have a generic class that is also a mapped super class that has a private field that holds a pointer to another object of the same type: @MappedSuperclass public abstract class MyClass<T extends MyIfc<T>> implements MyIfc<T> { @OneToOne() @JoinColumn(name = "previous", nullable = true) private T previous; ... } My problem is that Eclipse is showing an error in the file at the OneToOne "Target Entity "T" for previous is not an Entity." All of the implementations of MyIfc are, in fact, Entities. I should also add that each concrete implementation that inherit from MyClass uses a different value for T (because T is itself) so I can't use the "targetEntity" attribute. I guess if there is no answer then I'll have to move this JPA annotation to all the concrete subclasses of MyClass. It just seems like JPA/Hibernate should be smart enough to know it'll all work out at run-time. Makes me wonder if I should just ignore this error somehow.

    Read the article

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