I got the following problem:
I have an array of char pointers
char *opts[] = { "-a", "--append", "-b" };
and a command name stored in
char cmd[] = "ls";
Now I need to compute all possible combinations, which I've done using the GNU Scientific Library and execute the command with the compute combinations.
The problem I have is ho...
Ok guys, i'm very beginner and trying to enter string to a char array using pointers..and then display what i've written.
There're two things i want to ask about. First , if i didn't want to specify a size for the array and just want it to expand to contain all string i've entered ..how is that ?
And second after i enter the string and...
I am working on understanding recursion, and I think I have it down alright... I'm trying to build a search function (like the std::string.find()) that searches a given string for another string for example:
Given (big) string: "ru the running cat"
search (small) string: "run"
I'm trying to return a index for the where the wor...
hi ,
int * (*) (int * , int * (*)())
I'd like to know what type is it ? , can someone give an example of a declaration using this type.
any help would be great.
thanks.
...
Firstly, sample codes:
Case 1:
typedef char* CHARS;
typedef CHARS const CPTR; // constant pointer to chars
Textually replacing CHARS becomes:
typedef char* const CPTR; // still a constant pointer to chars
Case 2:
typedef char* CHARS;
typedef const CHARS CPTR; // constant pointer to chars
Textually replacing CHARS becom...
Hi all ,
This is my second problem today, pointers are giving me nightmares .
I'm trying to make a program that do the same thing that strcpy() function do..
Once i try it..it crashes and i'm 100% sure that's a pointers issue in my code. I think because there is some sort of an unintiallized pointer(*copied) ..But i've assigned NULL to i...
In VB6 I'm making a call to the Windows API DnsQuery.
Private Declare Function DnsQuery Lib "dnsapi" Alias "DnsQuery_A" ( _
ByVal lpstrName As String, _
ByVal wType As Integer, _
ByVal Options As Long, _
ByVal pServers As Long, _
ppQueryResultsSet As Long, _
ByVal pReserved As Long) As Long
Private Type VBDnsRecord
...
I am having trouble understanding how to assign memory
to a double pointer.
I want to read an array of strings and store it.
char **ptr;
fp=fopen("file.txt","r");
ptr=(char**)malloc(sizeof(char*)*50);
for(int i=0;i<20;i++)
{
ptr[i]=(char*)malloc(sizeof(char)*50);
fgets(ptr[i],50,fp);
}
instead of thi...
Hi I have a text file containing two arrays and one value(all integers)
like this
3 90 22 5 60 33 24
Where the first number stands for how many integers to read in.
I can read in all this in one function.
Do I need several functions to be able to use the different matrices and the first variable?
ifstream in(SOMEFILE.dat);
if...
Objective c | xcode | iphone question
Im building a model(data) class for a monetary transaction and have kind of a basic/noob question regarding pointers and object copying. The Transaction class I'm creating contains 4 or 5 ivars/properties that represent object type variables. now when I get the user entered data from the view contro...
Hi!
It might be that the problem is straight forward but I don't get my head around it.
I have the following iPhone code
for(int x = 0 ; x < [allFriends count] ; x++)
{
Friend *f = [[Friend alloc] init];
f = [allFriends objectAtIndex:x];
if([uid isEqualToString:[f uid]])
{ ...
Help me in solving 2 questions on pointers:
1)Please tell me why do I get 'segmentation fault' when I run following snippet
main()
{
char *str1 = "united";
char *str2 ="front";
char *str3;
str3 = strcat(str1,str2);
printf("\n%s",str3);
}
2)Why don't I get output in following code:
main()
{
...
I'm trying to debug a program I've written. According to the debugger a particular void * holds the value 0x804b008. I'd like to be able to dereference this value (cast it to an int * and get it's value).
I'm getting a Segmentation Error with this code. (The program with the void * is still running in the background btw - it's 'paused')...
Possible Duplicate:
What are the barriers to understanding pointers and what can be done to overcome them?
Was just wondering if anyone could "point me" to a good tutorial on pointers
Would be very greatful
Thanks
...
Can someone check my understanding and correct me if i am wrong?
int p = 5; //create an int holding 5
int *ptr; //create a pointer that can point to an int
*ptr = &p; // not sure - does this mean that my pointer now points to memory address five, or that the memory address my pointer points at contains 5?
Sorry for the basic questio...
I am posting a code.
using System;
using System.Runtime.InteropServices;
class TestPointer
{
public static void Main(string[] args)
{
if (args.Length == 0)
{
unsafe
{
int t = 8;
int* p = &t;
IntPtr addr = (IntPtr)p;
...
GCC gives me an "array type has incomplete element type"-error message when i try to compile this:
typedef struct _node node;
struct _node{
int foo;
node (*children)[2];
int bar;
};
In memory the struct should look like this
0x345345000000 foo
0x345345000004 pointer to 1. child node
0x345345000008 pointer to 2. child node
0x345345...
I have an (for C++ programmers better than me) simple problem with classes and pointers.
I thought about posting example code describing my problem but I found it easier to just explain it in words.
Assuming I have three classes:
Class A: The main class - it contains an instance of both B and C.
Class B: This class contains a method t...
Hi, i was hoping for some help, opposed to full solutions and i have an idea that i need to know what i am doing wrong when trying to implement
basically i am trying to remove spaces from the end of an array of characters in c
this is what i am doing
i have a method to work out the length of the string and store it in to an int
i se...
I am trying to remove spaces from the end of a char array (string).
This is the pseudo code of what I am doing, but it keeps deleting the whole string:
if(string length - 1 != a space)
return
Otherwise, it must equal a space, so
while *mypointer-- != a space
//This should loop back to where there is a character.
Outside of the...