Programming :: Two Pointers, That Have The Same Address Point To Different Values?
Feb 17, 2011
I have the most strange problem ever in programming. I fork a process into a parent and a child. In every forked process i declare a pointer, malloc and define a different value for every pointer.When i printf the value and the address guess what? They both have the SAME ADDRESS but DIFFERENT values, as assigned..Here's the portion of my code:
pid = fork ();
switch (pid)
{
[code]....
View 8 Replies
ADVERTISEMENT
Jan 29, 2011
I have a .txt file with the format
0.01
0.04
0.07
...
0.83
I am wanting to load this into octave and perform operations on the data.
[Code]...
View 2 Replies
View Related
Mar 27, 2010
I wonder why arrays in the C programming language are pointers to the first element of the array, not the first element of the array itself?
View 14 Replies
View Related
Sep 13, 2010
i'm practicing in very basic c programs using the gcc compiler.I found that when i create two variables let's say
Code:
int a,b and Code: a=15;
b=3;
a=b;
b--;
then a equals 2.I thought that this isn't normal in C isn't it?I haven't had the time to read the gcc documentation yet...so i think it has something to do with my compiler's default settings.I use the
Code: gcc filename.c -o filename command to compile
Are all variables defined like pointers?
View 5 Replies
View Related
Mar 23, 2010
So the place where I'm having a problem is here:
Code:
typedef struct {
void **Mem_Chunk;
[code]...
View 10 Replies
View Related
Jun 1, 2010
What is the difference between *ptr++ and (*ptr)++. In my opinion the terminology is all over the place so if you could give an example it would be better.
View 8 Replies
View Related
May 23, 2010
i'm a bit stuck playing with the following class setup for glut. The actual issue is with the function pointers.Basically the following code is the opengl redbook cube example slightly modified.
View 2 Replies
View Related
Jul 14, 2011
I need to call functions that match an input string (if input str = "func1", call func1), so I have this:
Code:
#include <stdio.h>
#include <string.h>
void function_a(void) { printf("Function A
"); }
[Code].....
In the above example, the functions take no input arguments. Can they take a different number of arguments, for example, function_a(int), function_c(int, int), function_e(int, char, int)? How can I do that?
View 3 Replies
View Related
Apr 12, 2010
I want to know is there some more efficient way of passing a pointer to a local variable as a parameter to a function in x86 asm? Right now I have to move the base pointer to a temp register, subtract from the register and pass that, like this (assuming a local var at esp-4):
Code:
mov eax, ebp
sub eax, 4
push eax
Is there a better way?
View 8 Replies
View Related
Feb 18, 2010
I'm trying to figure out how to code for this specific type of instance - I want to use a hash and have the key be a reference to an array, and not use the key in the standard way of it being a scalar. Basically, I have a large output that I need to process line by line, and rather have access to it as an array than a big block in a scalar. For the big block hash as a scalar I would do -
Code:
foreach $CONTROLLER (<CONTROLLER_LIST>) {
$ALL_DISKS{$CONTROLLER} = `ssh -n <commands>`;
}
Now I know I could take the scalar and split it to another array after the fact like -
Code:
@TEMP_HOLD = split (/s+/,$ALL_DISKS{$CONTROLLER});
How would I code it that I would have access to the key information as an array and not a scalar? I know it needs to be a pointer and we're going to have -> in there somewhere, but not sure how to approach it. Some of the documentaiton I've been reading about referencing I've found a little confusing so far, and trying to figure out how to use them in context of what I'm working on.
View 1 Replies
View Related
Jul 3, 2010
I've seen all three uses:
type * pointer
type *pointer
type* pointer
Are these 3 forms essentially the same, i.e., is the spacing as used here a non-factor when declaring pointers?
View 2 Replies
View Related
Mar 25, 2010
I am trying to find a way to pull Node Pointers out of the model, for use in other areas of the program. The solution is probably simple but I haven't had any luck finding it.
Model for a QTreeView:
Code:
class testModel : public QAbstractItemModel
{
public:
testModel();
~testModel();
[code]....
View 2 Replies
View Related
Jul 2, 2010
I following structure
typedef struct
{
[code]...
View 5 Replies
View Related
May 26, 2011
I have a 10x2 matrix, I create said matrix and fill it one column with zeros and the other with ones, now when I print the matrix I get this:
column 1:
0,0,0,0,0,0,0,0,1,1
column 2:
1,1,1,1,1,1,1,1,1,1
The first two rows of the second column are being replaced into the last two rows of the first column, now I even checked in visual studio and it works fine there. A friend tried my code and he gets it even worse:
column 1:
0,0,0,0,1,1,1,1,1,1
column 2:
1,1,1,1,1,1,1,1,1,1
As far as I've seen it must be a problem with GCC, unfortunately I need to have this up and running in GCC no matter what.
[Code].....
View 6 Replies
View Related
Apr 4, 2011
I want to point my apache to ip address. Before this I point it to my /var/www/spec and I want to change it to ip address. So that when I enter my ip address my script code will appear.
View 1 Replies
View Related
Jun 13, 2011
I want to do some basic web hosting, mainly for the experience. I have verizon fios for my isp, and what i am wondering is can i have the public ip address that they give me when i connect out to the internet point back to my linux box?
The reason that i am asking this is because i want to register a .com and i would like to have that point back to my linux box, i have looked at a few services and it seems that godaddy.com will do this and they seem to be the best choice. Before i register the .com i turnd on my httpd server but i am not sure how to get the public ip point back to my box...?
I have been doing some research and i am learning about things such as
ddclient
openvpn
port forwarding
nat
dynamic dns
Verizon fios like most isp's uses a dhcp connection meaning that the public ip address i get will change 1-2 a year. What i don't know is how can i setup my network at home preferably with iptables to have that public ip routed back to my linux box at home? I am using fedora 15 for those that are wondering...
Also when i enabled port forwarding and started my web server and tried loading http://mypublicipaddress in firefox i am directed to a verizon page with a login and password prompt.
I am aware that i will need to get certain information from my isp to have their public ip address routed back to my linux box but i am unware of what to ask them...?
If anyone here can tell me the following i will be so happy because it seems like a lot to hosting at home but i really want to learn...
here is what i need to know?
1) What kind of questions and information do i need to ask and get from my isp? DNS info? Logins and Passwords?
2) What do i need to do on my linux box to have that public ip address routed back to my linux box at home?
3) What rules do i need to add to my iptables script to allow this, i know there are certain nat rules that need to be added and port forwarding is needed as well..
4) anything else you can think of that i need to do...
View 9 Replies
View Related
Sep 4, 2010
I am trying to point my domain to my server with a static IP address. My domain is registered with Network Solutions and they ask "Primary and Secondary DNS" settings in their setup. What primary and secondary DNS settings I need to give when I have a dedicated server with static single IP address with BIND installed.
View 1 Replies
View Related
Oct 12, 2010
i am having two small issues with a function i have made.sorry if it is a mess, i am still learning bash.the first is calling the nonpersistssh function (second line) and assigning the return value to nonpersistdiag.the function returns 1, but nonpersistdiag seems to only contain 0. i am unsure on how to proceed.the second problem is the nested else clause on line 10. it is a syntactical error. how would i declare it correctly?
Code: function endsession(){
nonpersistdiag=$[nonpersistssh]# a function that returns an exit code
sudo /etc/init.d/ssh stop; sshdiag=$?
[code]....
View 6 Replies
View Related
Apr 1, 2011
I want to pass ip address,port address and some parameters from command line using python script.The ip address and port address for establishing socket connection and remaining parameters to execute different connection.
View 1 Replies
View Related
Feb 21, 2011
if i attach a shared memory to my process whch part of the address space it will add(like stack, heap, data, code...).
View 3 Replies
View Related
Nov 11, 2010
I can use hexedit to manually edit one or two hex values in a binary file, but if I want to change many of the, this is impractical. Is there any tool that will take parameters like Code: someTool filename byteNumber replacementByte ?
View 3 Replies
View Related
Jul 2, 2009
The idea is to make a website to check the availability of domains and it works but its not pretty yet. Below is what i have till so far:
## this is the API from my domain registrar.
<?php $client = new SoapClient('http://api.sync.com/?wsdl');
## I have a search box that sends the request to this page
$var = $_GET ["s"];
## remove the most common subdomains from the request.
$var=eregi_replace("www.", "", $var);
$var=eregi_replace("mail.", "", $var);
$var=eregi_replace("ftp.", "", $var);
$var=eregi_replace("pop.", "", $var);
$var=eregi_replace("smtp.", "", $var);
## remove any TLD extension from the request.
$split = explode(".", $var);
$main = $split[0];
$arraysize = sizeof($split);
for ($x=1; $x<$arraysize; $x++) {
$tld .= "." . $split[$x];
}
## login to the API
$paramLogin = array('handle' => 'randall', 'password' => 'password');
## match the domain with any possible TLD
$varcom = $paramAvailDomain = array('sld' => $main, 'tld' => 'com');
$varnet = $paramAvailDomain = array('sld' => $main, 'tld' => 'net');
$varorg = $paramAvailDomain = array('sld' => $main, 'tld' => 'org');
$varbiz = $paramAvailDomain = array('sld' => $main, 'tld' => 'biz');
$varinfo = $paramAvailDomain = array('sld' => $main, 'tld' => 'info');
$vareu = $paramAvailDomain = array('sld' => $main, 'tld' => 'eu');
$varnl = $paramAvailDomain = array('sld' => $main, 'tld' => 'nl');
$varbe = $paramAvailDomain = array('sld' => $main, 'tld' => 'be');
$varde = $paramAvailDomain = array('sld' => $main, 'tld' => 'de');
$varcouk = $paramAvailDomain = array('sld' => $main, 'tld' => 'co.uk');
$varorguk = $paramAvailDomain = array('sld' => $main, 'tld' => 'org.uk');
$varname = $paramAvailDomain = array('sld' => $main, 'tld' => 'name');
$varmobi = $paramAvailDomain = array('sld' => $main, 'tld' => 'mobi');
$varin = $paramAvailDomain = array('sld' => $main, 'tld' => 'in');
$vartv = $paramAvailDomain = array('sld' => $main, 'tld' => 'tv');
$varcn = $paramAvailDomain = array('sld' => $main, 'tld' => 'cn');
$varws = $paramAvailDomain = array('sld' => $main, 'tld' => 'ws');
$varnu = $paramAvailDomain = array('sld' => $main, 'tld' => 'nu');
$varbz = $paramAvailDomain = array('sld' => $main, 'tld' => 'bz');
$varcc = $paramAvailDomain = array('sld' => $main, 'tld' => 'cc');
## this requests the domain.COM and domain.NET
$varcom;
$varnet;
?>
<div id="content">
## below prints the result
<?php
print "<html><body><pre>";
$result1 = $client->__soapCall('Login', $paramLogin);
echo "<b>Result Login:</b>
" . print_r($result1, true);
$result15 = $client->__soapCall('AvailabilityDomain', $varcom);
$resvarcom = var_dump($result15, true);
$result15 = $client->__soapCall('AvailabilityDomain', $varnet);
$resvarnet = var_dump($result15, true);
print "</pre></html>";
?>
<?php
## the returned array looks like this
Result Login:
Array
(
[code] => 200
[message] => Login succesful
)
array(3) {
["code"]=>
string(3) "200"
["message"]=>
string(20) "Domain not available"
["result"]=>
object(stdClass)#236 (1) {
["status"]=>
string(5) "TAKEN"
}
}
bool(true)
array(3) {
["code"]=>
string(3) "200"
["message"]=>
string(16) "Domain available"
["result"]=>
object(stdClass)#232 (1) {
["status"]=>
string(4) "FREE"
}
}
bool(true)
?>
## till so far it works
What I need to do is to make this ugly looking reply in to something more readable, basically if TAKEN print occupied and if free print its yours to grab. I have been struggling with the in_array function but i'm not getting anywhere close in getting it to work.
View 2 Replies
View Related
Jul 11, 2010
I have been reading the Wikibook on C Programming for quite some time and am up to the variable part. I did learn several new things, like that too many variables hog memory.
What I want to know is how to assign a variable to the keyboard (in the C/C++ family) as such that the user has to type it in.
View 2 Replies
View Related
May 23, 2010
I have the following snippet HTML code:
Quote:
<table id="profile">
<tr>...............</tr>
<tr>
<td width="40%">
[Code].....
How can pass values in args[0] and args[1] to Perl/CGI script?
View 2 Replies
View Related
Jun 13, 2009
I created a class which has to return an array. My problem is I need to return 3 entries per record for example:
Code:
array(
"2009-06-13", "John", "Doe";
"2009-06-13", "Paul", "Simon";
"2009-06-12", "Frank", "Herbert";
);
Can this be done? What is the syntax? Where is the documentation? If this can't be done, How would you return this to a class without using a DB?
View 3 Replies
View Related
Feb 24, 2009
I have a application in C++, and now I have two class. MyDialog is the class that main function launch. In MyDialog class there are four elements and when I click over theese elements, there is a MousePressEvent that launch other class, Touchpad class. So, in some moments, I have loaded two class. My question is, how can pass a value from Touchpad class to MyDialog class, when I close (destroy) Touchpad class. In a few words, is it possible to communicate values between class?
View 5 Replies
View Related
Apr 6, 2011
I need a small shell based program that prints the mac address of physical ethernet adapter from it's firmware. I need this utility for license generation and appliance activation. I have tried several example but none of them is flawless, The easiest method I have found is to parse the output of "ifconfig" command but it has also some drawbacks.
1. Firstly program should differentiate between physical and virtual adapters. Physical means installed on board(wired or wireless) or installed additionally. Virtual adapters are those created by VPN or created by virtualization apps such as VirtualBox/VMWare etc. I am not interested in virtual ones.
2. In case of more them one physical adapters(wired and wireless), it should print the mac address and description(name & vendor) of both/all adapters.
3. If media is disconnected then also it should be able to read the mac address and description(name, vendor) of card.
4. This one is bit complex. I know that 'ethtool' can show you the universal mac address but it's limited to use only 2 types of drivers and won't work in all cases.
View 2 Replies
View Related
Nov 18, 2009
I want to translate the virtual address to physical address in linux C application, how to do that?
View 1 Replies
View Related
Sep 11, 2014
I am developing a script to automate some database setup, but I have an issue I cannot figure out. I prompt for some input with whiptail and select a default if nothing is entered. However, if you do not enter anything, it normally returns 0, but this time it is returning an empty value.
Code: Select all # This one does work!
# Set the source path
TMPPATH=$(whiptail --backtitle "Linux Build Configuration"
--title "Source-Code Path"
--inputbox "Default: $SRCPATH" 0 60
3>&2 2>&1 1>&3)
[Code] ....
So what is wrong with the second code?
View 1 Replies
View Related
Jan 24, 2010
Does anyone know what the Inet/AMD instruction 'nopl' is or does anyone know where I can find a list of hex values for the Intel/AMD instructions. nothing important is waiting on this reply.
[Code]...
View 3 Replies
View Related