In the following code I get a segmentation fault:
Set *getpar() {...}
char function(...)
{
Set **S;
*S = getpar(); /* Segmentation Fault */
...
}
But the bizarre thing is that with few changes there is no segmentation fault:
Set *getpar() {...}
...
char function(...)
{
Set *S; // One less '*'
S = getpar(); // ...
plz explain the follwing result of the stack smash after running a programming in which input i gave is much more than the capacity of the charachter array.
*** stack smashing detected ***: ./a.out terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x48)[0xb7f856d8]
/lib/tls/i686/cmov/li...
A textbook I recently read discussed row major & column major arrays. The book primarily focused on 1 and 2 dimensional arrays but didn't really discuss 3 dimensional arrays. I'm looking for some good examples to help solidify my understanding of addressing an element within a multi-dimensional array using row major & column major arra...
Hello. I'm writing a program in which you enter words via the keyboard or file and then they come out sorted by length. I was told I should use linked lists, because the length of the words and their number aren't fixed.
should I use linked lists to represent words?
struct node{
char c;
struct node *next;
};
And then how can...
Update: Please file this under bad ideas. You don't get anything for free in life and here is certainly proof. A simple idea gone bad. It is definitely something to learn from however.
Lazy programming challenge. If I pass a function that 50-50 returns true or false for the qsort's comparision function I think that I can effectively...
Back in the early 1990's, I used a library of routines in C called TCXL. I just wonder what ever happened to the guys who made that. I was about 25 years old the time, and learned C from a manual I printed out on my dot matrix printer. I think was using Turbo C, and I guess I downloaded TCXL from some bulletin board, or maybe Compuserve?...
It is mostly out of boredom, really... This afternoon I decided to make a simple 3D Game on Cocoa & OpenGL based on what I've done on one of my OpenGL class. I'm using the MD2 loading code that is posted at David Henry's "The Quake II's MD2 file format" and I like how it's put together, giving nice explanations, and nice C++ code. I wan...
Update2:
Ported to autotools and uploaded to SourceForge.
Update:
I am going to run a few more rigorous tests on this but I believe the issue is related to caching and ordering of the two test cases may be significant. Also I know the encryption is pathetic, duplicated in two files, and the code is less than first draft quality. I ...
I have a struct called ball, a number of balls, an array of balls and a function where I want to add new balls to the array:
The struct:
typedef struct ball{
BITMAP *image;
int x;
int y;
int vector_x;
int vector_y;
} ball;
The (non working function):
void add_balls(int *num_balls, ball **myballs){
num_balls++...
Are there free C/C++ and Java implementations of the point-to-point protocol (PPP) for use over a serial line? The C/C++ implementation will go into embedded hardware so portability is a concern. I'm not looking for a full TCP/IP stack, just something to provide a connection-oriented base to build on top of.
...
I have a question for all the hardcore low level hackers out there. I ran across this sentence in a blog. I don't really think the source matters (it's Haack if you really care) because it seems to be a common statement.
For example, many modern 3-D Games have their high performance core engine written in C++ and Assembly.
As far...
I have the following C code:
#define PRR_SCALE 255
...
uint8_t a = 3;
uint8_t b = 4;
uint8_t prr;
prr = (PRR_SCALE * a) / b;
printf("prr: %u\n", prr);
If I compile this (using an msp430 platform compiler, for an small embedded OS called contiki) the result is 0 while I expected 191.
(uint8_t is typedef'ed as an unsigned char)
If I ch...
Hi,
I have a simple OpenGL application where I have 2 objects displayed on screen:
1) particle system, where each particle is texture mapped with glTexImage2D() call. In the drawEvent function, I draw it as a GL_TRIANGLE_STRIP with 4 glVertex3f.
2) a 3D text loaded from an object file, where each point is loaded using glNewList/glGenLi...
I'm POSTing data to a HTTPS server using libcurl compiled with openssl using Visual Studio 2008 in windows and it all works fine with CURLOPT_SSL_VERIFYPEER set to 0. I've tried following http://curl.haxx.se/docs/sslcerts.html and just about every "SSL and SECURITY OPTIONS" option in the manual. I'm wondering what the right combination o...
Hey everybody,
What would be a good way to determine if a string contains an IP address. Should I use isdigit()?
Suggestions would be appreciate it.
Thanks
...
In other words, does the .NET framework eventually make calls somewhere to get its work done? Or did Microsoft completely re-create all the functionality of the win32 library in their .NET framework.
Thanks!
...
Part 1
In C, is there any difference between declaring an enum like this:
typedef enum{VAL1, VAL2,} firstEnum;
and like this:
enum secondEnum{Val1, Val2,};
Apart from the fact that when using secondEnum, you have to write:
enum secondEnum...;
Part 2
Also, am I right in thinking that the following is equivalent:
enum{Val1, Val...
Is the last comma required in a C enum declaration?
i.e. is the comma after VAL3 required?
enum{Val1, Val2, Val3,} someEnum;
Are there any side-effects of leaving it in/out
Thanks
...
I need to write a client-server application. I want to write it in python, because I'm familiar with it, but I would like to know if the python code can be ran from C. I'm planning to have two C projects, one containing the server code, and one containing the client code.
Is it possible to eval the python code and run it ? Is there anot...
I'm busy getting to know a tiny bit of C/C++, and interop with C#. I've checked several examples of creating a simple Win32 DLL and using this from C#, but when I try and call into my DLL, I get the runtime error: "Unable to find an entry point named TestFunc". My DLL looks like this, and I created it from a Win32 DLL project, with the...