Programming :: C++ Check If Pointer Is Deleted?
Apr 24, 2011
Is it possible to check if a pointer is deleted in C++ (using GDB)? For example:
Code:
a = new Thing();
b = a;
delete a;
// If all I have is the variable "b", how can I tell if it was deleted?
View 14 Replies
ADVERTISEMENT
Jun 27, 2009
I have been googling trying to fix this ... basicly I have a (int **) variable, and when I try to pass a (int) value to a specific position, I have seg.fault.Resuming what I have is:
int ** p;
p[0][0] = 1; //segmentation fault
View 7 Replies
View Related
Feb 10, 2010
How can I check if Ubuntu deletes all the content in /tmp folder at each shutdown
(without trial and error)?
How can I tell Ubuntu to delete it?
What about the deletion of other tracks like swapfile at shutdown?
View 6 Replies
View Related
Aug 19, 2010
I want to put check menu & check list in utility dialog.i dont know how i do this
View 1 Replies
View Related
Mar 20, 2010
So far I have this:
Code:
int mm_init (mm_t *MM, int hm, int sz) {
int i;
[code]...
View 4 Replies
View Related
Jul 6, 2010
I'm trying to write a simple program that lists a menu and then asks you for your decision, and you can answer with a number or the name. However, I don't know how to add the second options (name).
View 14 Replies
View Related
May 19, 2011
#!/bin/bash
sed -n 8p file.txt
returns the 8th line to the StdOut.
If I assign the value to the variable line = $(sed -n 8p file.txt)
and now print it out with echo
echo $line
the line would be printed.
But what if the file has only 4 lines. What value would be assigned to the variable line?
I want to know that because I want to only print it if the value is "something", that is not null.
In Java for example I would do it like this...
String line = "";
line = reader.readLine(); // or anything else..
if(line!=null){
System.out.println(line);
}
How would I check if the value is not "null"(I don't know if bash knows null)
View 13 Replies
View Related
Aug 23, 2009
Code:
#include <stdio.h>
int main ()
[code]...
View 7 Replies
View Related
Jul 26, 2010
Whats the practical diffrens between these declarations in c?
char *a_str = "hello";
char a_str[] = "hello";
View 4 Replies
View Related
Jul 12, 2010
i was trying to access the address of the character pointer it gives me the values stored in the variable.
Code: #include<iostream>
using namespace std;
int main()
{
char *i;
[Code]....
why is my code not giving the address of the variable i when it is a character pointer.
View 2 Replies
View Related
Jul 15, 2010
I'm getting some information about C language and this session of a C book (follow the above link) is using a bad example for me. When I'm trying this example of function returning a pointer, my compiler is stating a warning that I return a pointer to a local variable. I realized that it is error prone after all this variable may be override before the function has done his execution. And the author is fooling me saying that this example is "perfectly safe". I'm wrong? There is something that I don't got yet? Sorry but this site is preventing me to post the link of book cause I'm a newbie, so a need the hack it. Just strip out the question signs:
{LINK}
?w?w?w
?cs.cf.ac.uk?
[code]....
View 6 Replies
View Related
Dec 20, 2010
I want to assign an address location to a pointer and wanted to display the value at that memory location.I wrote a small program for this and it is like this : (i am using gcc 4.4 compiler)
# include "stdio.h"
int main()
{
unsigned int *a;
a=(unsigned int *)0x3f8;
printf("%u",*a);
return 0;
}
But it is giving Segmentation fault
View 14 Replies
View Related
Mar 10, 2009
i am trying to find the size of an array, not by using the array as a parameter to "sizeof", but by using a pointer -pointing to the array- as a parameter. How do i do this?I use a 32-bit PC.Here's:
Code:
#include <string>
#include <iostream>
[code]...
View 2 Replies
View Related
Dec 8, 2010
This is one of the strangest problems I've run into while programming. Maybe there's just something wrong with my version of gcc or something.
The main problem comes at this point in the code:
Code:
po = makePoFromScorbotXYZPR(X, Y, Z, P, R);
h = makeHB2GFromPo(po);
printf("%le", *h[1][0]); //##################################### Here it has the right value
printf("%s", "
[Code].....
View 2 Replies
View Related
Sep 29, 2010
I have got following code from a book:
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdlib.h>
#define PORTNUMBER 12345
[Code]...
View 6 Replies
View Related
Feb 28, 2010
From "man gcc"
-Wno-int-to-pointer-cast (C and Objective-C only)
Suppress warnings from casts to pointer type of an integer of a different size.
[code]...
View 3 Replies
View Related
Sep 29, 2010
I have been trying to get a void pointer cast to work and I seem to have some problems. My code compiles, but when I execute it gives back garbage data. I'm not sure what I'm doing wrong.
Code:
int main()
{
[code]....
View 7 Replies
View Related
Feb 15, 2009
How could i create a script that will move the mouse pointer around the screen.i'm thinking i need the Xlib modules (which i have installed) but don't know how to implement them
View 5 Replies
View Related
Oct 18, 2010
How do I get the page pointer from a physical address?
View 1 Replies
View Related
Feb 5, 2011
I have a problem with correctly using a void pointer. I am writing a system that can open plugins and run them, and so far everything is going fine: I have a struct with some variables in, some function pointers, and I've written a small library to handle these correctly to communicate with the plugin. My challenge is that I need to put a pointer (let's call it "context") into this struct. The type is not important to the main body of code, and it is not ever used except by the plugin. The plugin will malloc some space for itself, and this *context will then point to whatever malloc returned. context is the address to a struct that I typedeffed to "ctxt".
Here is the first struct I mentioned:
Code:
typedef struct slave {
int val1;
int val2;
int (*entry)(struct slave*, int a, int b);
void *context;
} target;
Here are some snippets from the plugin:
Code:
typedef struct context {
int a;
int b;
} ctxt;
(*target).context = malloc(sizeof(struct ctxt));
So that (*target).*(ctxt)*context.a should refer to the int a in struct context.
But the error that the compiler gives me is a syntax one:
"expected identifier before '*' token"
Is my logic correct? Is my C correct?
View 11 Replies
View Related
Feb 5, 2011
I have what should be a relatively simple program (fadec.c) that maps a struct from an included header file (fadec.h) to a shared memory region, but Im struggling accessing members in the struct from the pointer returned by shmat. Ultimately, I want to access members in the shared memory structure with a globally declared version of the struct, shm__. Not only do I not know how to accomplish that, but I cant even seem to access members of the shared struct directly from the pointer itself (compiler complains about dereferencing pointer to incomplete type). Im at a loss and could use another set of eyes if you guys dont mind taking a gander:
Compile Errors:
tony-pc:/cygdrive/p/test> cc -o fadec fadec.c
fadec.c: In function 'main':
fadec.c:30: error: dereferencing pointer to incomplete type
fadec.c:31: error: dereferencing pointer to incomplete type
[Code]...
View 1 Replies
View Related
Mar 30, 2011
I'm venturing into the world of OpenGL, but in the process of writing my graphics library I ran into a problem... My code is:
Code:
#include <stdio.h>
#include <stdlib.h>
[code]...
View 5 Replies
View Related
Jan 21, 2011
Say, i have an imaginary std library function, which I want to call.
Code:
void std_lib_func(ObjectType *param);
Now in my c++ program, I have a main() function, and I will like to call a customized function (which will in turn call the std lib function) from the main function, as below:
Code:
int main()
{
ObjectType *aobj;
customized_func(aobj);
}
[Code]...
I tried the below but get an error that the std lib function is expecting a ObjectType* param, not aobj. How should I work this out.
Code:
void customized_func(ObjectType aobj)
View 4 Replies
View Related
May 13, 2009
Please look at the comments
Code:
/*
* TEST CASE TO CHECK DIFFERENCES BETWEEN STRING AS
[code]...
View 14 Replies
View Related
Aug 5, 2010
hey dude error in gnu c pointer
I am using Red Hat Enterprise Linux 5.0.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char * cp = NULL;
[Code].....
View 4 Replies
View Related
Feb 8, 2011
A friend working in HPC environments commented me that he had an issue regarding the use of the malloc() function.What issue?He told me that he has had cases in where malloc() instead of returning a NULL pointer on failure, simply didn't change the original value of the pointer it was trying to use for allocation, thus forcing him to initialize pointers to be allocated with malloc() to NULL, so that he could be sure that if malloc() fails, a test for NULL would make sense.
View 12 Replies
View Related
May 15, 2011
I am playing around with a new chat program and I have errors that I can not figure out. Here is what I am getting.
parse.c:1638: error: dereferencing pointer to incomplete type
parse.c:1638: error: dereferencing pointer to incomplete type
parse.c:1638: error: dereferencing pointer to incomplete type
here is the code:
if (scan->jail_timeout == 0 && scan->location == prison)
{
command_type |= HIGHLIGHT;
tell_player(scan, " After serving your sentence you are flung out"
[code]....
View 6 Replies
View Related
Oct 27, 2010
So unbeknownst to me until today, but apparently all configure scripts rely on some version of awk to create the Makefile when config.status is run.how to get gawk reinstalled?I have compiled one on Ubuntu and copied it to my other machine but when run it throws the error:Code:./gawk: no such file or directorySo I am guessing I either need to create a static copy or maybe also copy the libs created from compile with it.
View 7 Replies
View Related
Sep 29, 2010
I'm deleting logs after they are backed up. The line below in a script is doing it but I'd like to print the list of files that are deleted into a log file. I tried printf at the end but can't seem to get it to work. I'm not sure how to output that at the end of the string. Also I was looking at man find man and the difference btween -exec and -execdir. I don't understand what it's saying. Is -execdir executing rm m within the /opt/temp/logs directory the difference?
View 4 Replies
View Related
Apr 16, 2011
I need to call php function for fetching data from mysql but I dont want to move internal row pointer (IRP) forward. Or even get the actual IRP position then fetch data and move IRP back to remembered position. Function mysql_data_seek() is not suitable for my example because I am trying to fetch data recursive here is code (See the pseudocode commented section):
Code:
<?php
include_once("connection.php");
[code]...
View 1 Replies
View Related