Search Results

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

Page 4/144 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • C++ pointer, Beginner Question...

    - by BobAlmond
    Hi there, just want to ask a beginner question... here, I made some code, for understanding the concept/basic of pointer: int a=1; int *b=&a; int **c = &b; int ***d = &c; cout << &*(&*d) << endl; can someone explain to me, why the &*(&d) return address of "c" instead of address of "b"? I've also tried code like &(&(&(&*(&*d)))), but it keep return address of "c" Thanks a lot :)

    Read the article

  • C++ pointer to functions, Beginner Question...

    - by BobAlmond
    Hi all, I want to ask about pointer in C++ I have some simple code: int add(int a, int b){ return a+b; } int runner(int x,int y, int (*functocall)(int, int)){ return (*functocall)(x,y); } now, suppose I call those functions using this way : cout<<runner(2,5,&add); or maybe cout<<runner(2,5,add); is there any difference? because when I tried, the result is the same and with no error. Thanks a lot

    Read the article

  • Modifying a const through a non-const pointer

    - by jasonline
    I'm a bit confused what happened in the following code: const int e = 2; int* w = ( int* ) &e; // (1) cast to remove const-ness *w = 5; // (2) cout << *w << endl; // (3) outputs 5 cout << e << endl; // (4) outputs 2 cout << "w = " << w << endl; // (5) w points to the address of e cout << "&e = " << &e << endl; In (1), w points to the address of e. In (2), that value was changed to 5. However, when the values of *w and e were displayed, their values are different. But if you print value of w pointer and &e, they have the same value/address. How come e still contained 2, even if it was changed to 5? Were they stored in a separate location? Or a temporary? But how come the value pointed by w is still the address of e?

    Read the article

  • Go: using a pointer to array

    - by Sean
    I'm having a little play with google's Go language, and I've run into something which is fairly basic in C but doesn't seem to be covered in the documentation I've seen so far When I pass a pointer to an array to a function, I presumed we'd have some way to access it as follows: func conv(x []int, xlen int, h []int, hlen int, y *[]int) for i := 0; i<xlen; i++ { for j := 0; j<hlen; j++ { *y[i+j] += x[i]*h[j] } } } But the Go compiler doesn't like this: sean@spray:~/dev$ 8g broke.go broke.go:8: invalid operation: y[i + j] (index of type *[]int) Fair enough - it was just a guess. I have got a fairly straightforward workaround: func conv(x []int, xlen int, h []int, hlen int, y_ *[]int) { y := *y_ for i := 0; i<xlen; i++ { for j := 0; j<hlen; j++ { y[i+j] += x[i]*h[j] } } } But surely there's a better way. The annoying thing is that googling for info on Go isn't very useful as all sorts of C\C++\unrelated results appear for most search terms.

    Read the article

  • vector::erase with pointer member

    - by matt
    I am manipulating vectors of objects defined as follow: class Hyp{ public: int x; int y; double wFactor; double hFactor; char shapeNum; double* visibleShape; int xmin, xmax, ymin, ymax; Hyp(int xx, int yy, double ww, double hh, char s): x(xx), y(yy), wFactor(ww), hFactor(hh), shapeNum(s) {visibleShape=0;shapeNum=-1;}; //Copy constructor necessary for support of vector::push_back() with visibleShape Hyp(const Hyp &other) { x = other.x; y = other.y; wFactor = other.wFactor; hFactor = other.hFactor; shapeNum = other.shapeNum; xmin = other.xmin; xmax = other.xmax; ymin = other.ymin; ymax = other.ymax; int visShapeSize = (xmax-xmin+1)*(ymax-ymin+1); visibleShape = new double[visShapeSize]; for (int ind=0; ind<visShapeSize; ind++) { visibleShape[ind] = other.visibleShape[ind]; } }; ~Hyp(){delete[] visibleShape;}; }; When I create a Hyp object, allocate/write memory to visibleShape and add the object to a vector with vector::push_back, everything works as expected: the data pointed by visibleShape is copied using the copy-constructor. But when I use vector::erase to remove a Hyp from the vector, the other elements are moved correctly EXCEPT the pointer members visibleShape that are now pointing to wrong addresses! How to avoid this problem? Am I missing something?

    Read the article

  • getting Null pointer exception

    - by Abhijeet
    Hi I am getting this message on emulator when I run my android project: The application MediaPlayerDemo_Video.java (process com.android.MediaPlayerDemo_Video) has stopped unexpectedly. Please try again I am trying to run the MediaPlayerDemo_Video.java given in ApiDemos in the Samples given on developer.android.com. The code is : package com.android.MediaPlayerDemo_Video; import android.app.Activity; import android.media.AudioManager; import android.media.MediaPlayer; import android.media.MediaPlayer.OnBufferingUpdateListener; import android.media.MediaPlayer.OnCompletionListener; import android.media.MediaPlayer.OnPreparedListener; import android.media.MediaPlayer.OnVideoSizeChangedListener; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; import android.widget.Toast; public class MediaPlayerDemo_Video extends Activity implements OnBufferingUpdateListener, OnCompletionListener, OnPreparedListener, OnVideoSizeChangedListener, SurfaceHolder.Callback { private static final String TAG = "MediaPlayerDemo"; private int mVideoWidth; private int mVideoHeight; private MediaPlayer mMediaPlayer; private SurfaceView mPreview; private SurfaceHolder holder; private String path; private Bundle extras; private static final String MEDIA = "media"; // private static final int LOCAL_AUDIO = 1; // private static final int STREAM_AUDIO = 2; // private static final int RESOURCES_AUDIO = 3; private static final int LOCAL_VIDEO = 4; private static final int STREAM_VIDEO = 5; private boolean mIsVideoSizeKnown = false; private boolean mIsVideoReadyToBePlayed = false; /** * * Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.mediaplayer_2); mPreview = (SurfaceView) findViewById(R.id.surface); holder = mPreview.getHolder(); holder.addCallback(this); holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); extras = getIntent().getExtras(); } private void playVideo(Integer Media) { doCleanUp(); try { switch (Media) { case LOCAL_VIDEO: // Set the path variable to a local media file path. path = ""; if (path == "") { // Tell the user to provide a media file URL. Toast .makeText( MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video Activity, " + "and set the path variable to your media file path." + " Your media file must be stored on sdcard.", Toast.LENGTH_LONG).show(); } break; case STREAM_VIDEO: /* * Set path variable to progressive streamable mp4 or * 3gpp format URL. Http protocol should be used. * Mediaplayer can only play "progressive streamable * contents" which basically means: 1. the movie atom has to * precede all the media data atoms. 2. The clip has to be * reasonably interleaved. * */ path = ""; if (path == "") { // Tell the user to provide a media file URL. Toast .makeText( MediaPlayerDemo_Video.this, "Please edit MediaPlayerDemo_Video Activity," + " and set the path variable to your media file URL.", Toast.LENGTH_LONG).show(); } break; } // Create a new media player and set the listeners mMediaPlayer = new MediaPlayer(); mMediaPlayer.setDataSource(path); mMediaPlayer.setDisplay(holder); mMediaPlayer.prepare(); mMediaPlayer.setOnBufferingUpdateListener(this); mMediaPlayer.setOnCompletionListener(this); mMediaPlayer.setOnPreparedListener(this); mMediaPlayer.setOnVideoSizeChangedListener(this); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); } catch (Exception e) { Log.e(TAG, "error: " + e.getMessage(), e); } } public void onBufferingUpdate(MediaPlayer arg0, int percent) { Log.d(TAG, "onBufferingUpdate percent:" + percent); } public void onCompletion(MediaPlayer arg0) { Log.d(TAG, "onCompletion called"); } public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { Log.v(TAG, "onVideoSizeChanged called"); if (width == 0 || height == 0) { Log.e(TAG, "invalid video width(" + width + ") or height(" + height + ")"); return; } mIsVideoSizeKnown = true; mVideoWidth = width; mVideoHeight = height; if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) { startVideoPlayback(); } } public void onPrepared(MediaPlayer mediaplayer) { Log.d(TAG, "onPrepared called"); mIsVideoReadyToBePlayed = true; if (mIsVideoReadyToBePlayed && mIsVideoSizeKnown) { startVideoPlayback(); } } public void surfaceChanged(SurfaceHolder surfaceholder, int i, int j, int k) { Log.d(TAG, "surfaceChanged called"); } public void surfaceDestroyed(SurfaceHolder surfaceholder) { Log.d(TAG, "surfaceDestroyed called"); } public void surfaceCreated(SurfaceHolder holder) { Log.d(TAG, "surfaceCreated called"); playVideo(extras.getInt(MEDIA)); } @Override protected void onPause() { super.onPause(); releaseMediaPlayer(); doCleanUp(); } @Override protected void onDestroy() { super.onDestroy(); releaseMediaPlayer(); doCleanUp(); } private void releaseMediaPlayer() { if (mMediaPlayer != null) { mMediaPlayer.release(); mMediaPlayer = null; } } private void doCleanUp() { mVideoWidth = 0; mVideoHeight = 0; mIsVideoReadyToBePlayed = false; mIsVideoSizeKnown = false; } private void startVideoPlayback() { Log.v(TAG, "startVideoPlayback"); holder.setFixedSize(mVideoWidth, mVideoHeight); mMediaPlayer.start(); } } I think the above message is due to Null pointer exception , however I may be false. I am unable to find where the error is . So , Please someone help me out .

    Read the article

  • High end mobile workstations with pointer stick

    - by Elijah Lynn
    I am looking for a list of higher end mobile workstations that run Ubuntu/Kubuntu well and also have a hardware pointer stick. Here's an illustration of one (from sciencesurvivalblog): I wouldn't mind getting a Macbook Pro and wiping it but they refuse to use pointer sticks and to me, they are extremely efficient. I see a lot of potential for Lenovo thinkpads as well. System 76 said they have no plans to implement a hardware pointer stick so that leaves them out as well. Any ideas?

    Read the article

  • USB mouse pointer only moving horizontally on macbook 6.2 with 12.04

    - by Glyn Normington
    After installing Ubuntu 12.04 on a macbook pro 6.2, the touchpad and external USB mouse worked perfectly. After rebooting I can't get either touchpad or external USB mouse to work. Sometimes no mouse pointer is visible, but more often I can only move the mouse pointer horizontally five sixths of the way across the display (from the top left). I have uninstalled mouseemu. xinput list shows the USB mouse. xinput query-state for the USB mouse shows the following: ButtonClass button[1]=up ... button[16]=up ValuatorClass Mode=Relative Proximity=In valuator[0]=480 valuator[1]=2400 valuator[2]=0 valuator[3]=3 and re-issuing this command with the pointer at its right hand extreme displays the same except for: valuator[0]=1679 So the valuator[0] seems to be the x-coordinate of the pointer and the range of motion 480-1679 is indeed about five sixths of the display width (1440). valuator[1] is suspiciously large given the display height is 900. Perhaps this is a side-effect of having previously been using a dual monitor (although booting with that monitor connected does not help). There are other entries listed under xinput list: Virtual core XTEST pointer which seems stuck at position (840,1050). bcm5974 which seems stuck at position (837,6700). Removing the bcm5974 module using rmmod disables the toucpad as expected but does not fix the USB mouse problem. After adding the module back, it is stuck at position (840,1050) instead of (837,6700). /etc/X11/xorg.conf was generated by nvidia-settings and contains: Section "InputDevice" # generated from default Identifier "Mouse0" Driver "mouse" Option "Protocol" "auto" Option "Device" "/dev/psaux" Option "ZAxisMapping" "4 5" although I don't know how plausible these settings are. Any suggestions?

    Read the article

  • Mouse pointer hides at bad times after updating to 13.10

    - by Richard
    A bug, I think, though I can't even seem to find any information when searching for it. The mouse pointer hides itself, but it is still possible to use it. Whenever I start watching a video in VLC, or start playing KSP through Steam my mouse pointer disappears. It is not returned upon exiting the application. I have not tried with other games in Steam. The mouse pointer do not disappear when watching videos online through YouTube, though it properly hides itself after a few seconds. The bug came about after I updated to 13.10, it was not present with the same setup in 13.04. I have tried removing ~/.compiz and restarting the kernel module psmouse. Going to tty1 and back to the desktop reveals the pointer, though this fix is bothering me. How do I fix this problem?

    Read the article

  • Go - Pointer to map

    - by nevalu
    Having some maps defined as: var valueToSomeType = map[uint8]someType{...} var nameToSomeType = map[string]someType{...} I would want a variable that points to the address of the maps (to don't copy all variable). I tried it using: valueTo := &valueToSomeType nameTo := &nameToSomeType but at using valueTo[number], it shows internal compiler error: var without type, init: new How to get it?

    Read the article

  • How to avoid null pointer error

    - by Jessy
    I trying to find whether the elements of 2 arrayLists are match or not. But this code give me error Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException since some of the elements are null. How can I solved this problem? String level []={"High","High","High","High","High","High"}; ArrayList<Object> n = new ArrayList<Object>(Arrays.asList(level)); String choice []={null,"High","Low","High",null,"Medium"}; ArrayList<Object> m = new ArrayList<Object>(Arrays.asList(choice)); //Check if the two arrayList are identical for(int i=0; i<m.size(); i++){ if(!(m.get(i).equals(n.get(i)))){ result= true; break; } } return result; }

    Read the article

  • Classes, constructor and pointer class members

    - by pocoa
    I'm a bit confused about the object references. Please check the examples below: class ListHandler { public: ListHandler(vector<int> &list); private: vector<int> list; } ListHandler::ListHandler(vector<int> &list) { this->list = list; } Here I would be wasting memory right? So the right one would be: class ListHandler { public: ListHandler(vector<int>* list); private: vector<int>* list; } ListHandler::ListHandler(vector<int>* list) { this->list = list; } ListHandler::~ListHandler() { delete list; }

    Read the article

  • Why subtract null pointer in offsetof()?

    - by Bruce Christensen
    Linux's stddef.h defines offsetof() as: #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) whereas the Wikipedia article on offsetof() (http://en.wikipedia.org/wiki/Offsetof) defines it as: #define offsetof(st, m) \ ((size_t) ( (char *)&((st *)(0))->m - (char *)0 )) Why subtract (char *)0 in the Wikipedia version? Is there any case where that would actually make a difference?

    Read the article

  • Use super class's address/pointer in initialization list

    - by JQ
    context 1: class D : public B1, public B2{}; context 2: B2 takes B1 to initialize: B2( B1 * ) //B2's constructor my question is in D's initialization list: D::D() : B1(), B2( ? )... What should be in ? I don't want to put " (B1*)this " in the ? place, because it's no good to use "this" in initialization list. And since B1 part has been initialized, it makes sense to use it. What should I do ?

    Read the article

  • How to store a function pointer in C#

    - by Joshua
    Let's say I want to store a group of function pointers in a List<(*func), and then later call them, perhaps even with parameters... Like if I stored in a Dict<(*func), object[] params could I call the func with the parameters? How would I do this?

    Read the article

  • C++ vector pointer/reference problem

    - by sub
    Please take a look at this example: #include <iostream> #include <vector> #include <string> using namespace std; class mySubContainer { public: string val; }; class myMainContainer { public: mySubContainer sub; }; void doSomethingWith( myMainContainer &container ) { container.sub.val = "I was modified"; } int main( ) { vector<myMainContainer> vec; /** * Add test data */ myMainContainer tempInst; tempInst.sub.val = "foo"; vec.push_back( tempInst ); tempInst.sub.val = "bar"; vec.push_back( tempInst ); // 1000 lines of random code here int i; int size = vec.size( ); myMainContainer current; for( i = 0; i < size; i ++ ) { cout << i << ": Value before='" << vec.at( i ).sub.val << "'" << endl; current = vec.at( i ); doSomethingWith( current ); cout << i << ": Value after='" << vec.at( i ).sub.val << "'" << endl; } system("pause");//i suck } A hell lot of code for an example, I know. Now so you don't have to spend years thinking about what this [should] do[es]: I have a class myMainContainer which has as its only member an instance of mySubContainer. mySubContainer only has a string val as member. So I create a vector and fill it with some sample data. Now, what I want to do is: Iterate through the vector and make a separate function able to modify the current myMainContainer in the vector. However, the vector remains unchanged as the output tells: 0: Value before='foo' 0: Value after='foo' 1: Value before='bar' 1: Value after='bar' What am I doing wrong? doSomethingWith has to return void, I can't let it return the modified myMainContainer and then just overwrite it in the vector, that's why I tried to pass it by reference as seen in the doSomethingWith definition above.

    Read the article

  • How to check if a pointer is null in C++ Visual 2010

    - by mariomario
    I am having problems here if I want to check if eerste points to nothing i get Blockquote Unhandled exception at 0x003921c6 in Bank.exe: 0xC0000005: Access violation reading location 0xccccccd0. and i am kinda wondering why he justs skips the if statement or doens't stop when the object eerste points to nothing Bank::Bank() { LijstElement *eerste = NULL; LijstElement *laatste = NULL; } Rekening * Bank::getRekening(int rekNr) { if(NULL != eerste) { LijstElement *nummer = eerste; while(nummer->volgende!= NULL) { Rekening *een = nummer->getRekening(); if(een->getRekNr()==rekNr) { return een; } else { nummer = nummer->volgende; } } } return NULL; }

    Read the article

  • Allocating memory for a array to char pointer

    - by nunos
    The following piece of code gives a segmentation fault when allocating memory for the last arg. What am I doing wrong? Thanks. int n_args = 0, i = 0; while (line[i] != '\0') { if (isspace(line[i++])) n_args++; } for (i = 0; i < n_args; i++) command = malloc (n_args * sizeof(char*)); char* arg = NULL; arg = strtok(line, " \n"); while (arg != NULL) { arg = strtok(NULL, " \n"); command[i] = malloc ( (strlen(arg)+1) * sizeof(char) ); strcpy(command[i], arg); i++; } Thanks.

    Read the article

  • C++ pointer to different array

    - by begun
    Assume I have an array a and an array b. Both have the same type and size but different values. Now I create 3 or so pointers that point to different elements in a, you could say a[ 0 ], a[ 4 ] and a[ 13 ]. Now if I overwrite a with b via a=b - Where will the pointers point? Do the pointers still point to their original positions in a but the values they point to are now those of b?

    Read the article

  • C++: Copying to dereferenced pointer...

    - by bbb
    Hi. I currently have a weird problem with a program segfaulting but im not able to spot the error. I think the problem boils down to this. struct S {int a; vector<sometype> b;} S s1; // fill stuff into a and b S* s2 = new S(); *s2 = s1; Could it be that the final copying is illegal in some way? Im really confused right now... Thanks

    Read the article

  • Pointer-like behavior in Java

    - by Shmoo
    I got the following: class A{ int foo; } class B extends A{ public void bar(); } I got a instance of A and want to convert it to an instance of B without losing the reference to the variable foo. For example: A a = new A(); a.foo = 2; B b = a; <-- what I want to do. //use b b.foo = 3; //a.foo should now be 3 Thanks for any help!

    Read the article

  • Mouse pointer size inconsistent

    - by charon00
    Since installing Ubuntu 12.04, I've been having a problem with the mouse pointer size. On the desktop, it is quite a bit larger than it should be (24), though the different cursors (editing text, hyperlink hand, etc) are correct. The size changes to the correct size when the pointer is over some application windows (GVim, Netbeans, Firefox), but then changes back once it is moved out of the window. There was a similar question here, but the Xdefaults solution did not work for me, and I didn't want to try the one requiring editing the icon image. In addition, I've tried changing the cursor theme using sudo update-alternatives --config x-cursor-theme as well as using the dconf-editor, but though I can change the theme, the size issue remains. In case it's relevant, I'm running on a dual-screen setup with monitor sizes of 2560x1600 and 1920x1080, using the NVidia video driver. Is there another way to control pointer size, or a setting that might be messing it up? EDIT: These are the values/options I have for update-alternatives and in dconf-editor. I'm now wondering if Netbeans and Firefox are making the mouse pointer smaller than it should be, but I'm not sure how big 24 should be... update-alternatives: Selection Path Priority Status ------------------------------------------------------------ 0 /usr/share/icons/DMZ-White/cursor.theme 90 auto mode 1 /etc/X11/cursors/core.theme 30 manual mode 2 /etc/X11/cursors/handhelds.theme 20 manual mode 3 /etc/X11/cursors/redglass.theme 20 manual mode 4 /etc/X11/cursors/whiteglass.theme 20 manual mode * 5 /usr/share/icons/DMZ-Black/cursor.theme 30 manual mode 6 /usr/share/icons/DMZ-White/cursor.theme 90 manual mode dconf-editor: I can't post the image since I'm a new user but the cursor-size is set to 24 and the cursor-theme is DMZ-Black.

    Read the article

  • generic programming in C with void pointer.

    - by Nyan
    Hi everyone, even though it is possible to write generic code in C using void pointer(generic pointer), I find that it is quite difficult to debug the code since void pointer can take any pointer type without warning from compiler. (e.g function foo() take void pointer which is supposed to be pointer to struct, but compiler won't complain if char array is passed.) What kind of approach/strategy do you all use when using void pointer in C?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >