Simple question. I have a char pointer in a struct. When I try to free it, I get the following error at run time:
a.out(1186) malloc: *** error for object 0x1ffc: Non-aligned pointer being freed...
Type: Posts; User: cs32
Simple question. I have a char pointer in a struct. When I try to free it, I get the following error at run time:
a.out(1186) malloc: *** error for object 0x1ffc: Non-aligned pointer being freed...
Given the following code:
#include <stdio.h>
#include <stdlib.h>
typedef struct foo {
int test;
char b;
} foo;
I'm trying to create an array of pointers. I'm obviously way off base here.
OK - I'm a little bit confused. Why do I get a compiler warning with the following code:
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[]) {
int foo[5];
Here's a small piece of code that I'm having some trouble with.
typedef struct my_struct {
...
int *current_items;
} my_struct;
my_struct *s = malloc(sizeof(my_struct));...
Simple question for you guys:
Given the following struct:
typedef struct mystruct {
char *c;
int i;
} mystruct;
This is interesting -- how would I get started on writing my own shell?
Given the follow struct for a doubly linked list:
typedef struct Node {
int value;
struct Node *next;
struct Node *previous;
} nodeT;
What do you mean by "narrowing data conversion warnings"?
There's a space in between < and s. Removing this should fix your problem.
This is how I'd write it:
int
main(int argc, char *argv[]) {
char *s = "this is my string";
char *buf;
int i, x = 0;
My bad - thanks for correcting.
Sorry, esbo, I use a debugger. I guess I've doomed myself to never having a "sound grasp of C."
From time to time, I like to capture all of the information gleaned from threads that I've been tracking in this forum to a private wiki that I have running off my home server.
Based on the...
In this thread, which was unfortunately closed, brewbuck states:
What's the difference between a segment and a page? And what kind of access controls do we have? Read/write? Anything else? How...
Wow - a lot of activity in this thread. : )
My question was a purely abstract one. I was interested in knowing exactly what went on behind the scenes when a static variable was used in the context...
Forgive my ignorance, but how are you losing 4 bytes?
Post what you have so far and we'll help out.
Given the following code:
#include <stdlib.h>
#include <stdio.h>
int do_something(char *);
int
main(int argc, char *argv) {
By source file, I meant the *.c file. If I specify foo.h, does the compiler/program look for foo.c in the same location as foo.h?
Dumb question, but when you include a header file in a C program, how does the compiler/program know where to find the source file?
Sorry to hijack the thread, but when you free a Node, do you also have to manually free the pointers within, such as next and prev, or does freeing the Node automatically take care of that for you?
OK. This is what I have (headers intentionally excluded). Same compile error.
typedef struct nodeT node;
typedef struct {
int value;
node *next;
} nodeT;
I've run into a bit of a snag with the following code that is perhaps a result of me not fully understanding how to deal with pointers in a struct.
typedef struct {
int value;
struct nodeT...
Thanks for reviewing!
What do you mean?