Hey,
I did my own Socket class, to be able to send and receive HTTP requests.
But I still got some problems. The following code (my receive function) is still buggy, and crashing sometimes.
I tried debugging it, but it must be somewhere in the pointer arithmetics / memory management.
int Socket::Recv(char *&vpszRecvd)
{
//vpszRecvd =...
Hi!
I got a hw assignment asking me to invoke a function without explicitly calling it, using buffer overflow. The code is basically this:
#include <stdio.h>
#include <stdlib.h>
void g()
{
printf("now inside g()!\n");
}
void f()
{
printf("now inside f()!\n");
// can only modify this section
// cant call g(), maybe...
I want to concatenate a piece of text, for example "The answer is " with a signed integer, to give the output "The number is 42".
I know how long the piece of text is (14 characters) but I don't know how many characters the string representation of the number will be.
I assume the worst case scenario, the largest signed 16-bit integer ...
I can not get to make this comparison in this simple code error .. what kind I'm making and what is the reason? ...
#include <stdio.h>
int main()
{
double a = 0.0;
double b = 1.0;
double c = 0.1;
while( a != b )
a=a+c;
printf("Suma hasta 1 completada\n");
}
tnx for the answers...
...
I have this code segment in which I am opening/closing a file a number of times (in a loop):
for(i=1;i<max;i++)
{
/* other code */
plot_file=fopen("all_fitness.out","w");
for (j=0;j<pop_size;j++)
fprintf(plot_file, "%lf %lf\n",oldpop[i].xreal[0],oldpop[i].obj);
fclose(plot_file);
/*other c...
I've seen in many places that people often use the option -fomit-frame-pointer when compiling C / C++ code and I wonder, is the use of that option safe? What is it used for?
Thank you very much, best regards.
...
I have a list of devices and a bitmask of channels they are on (channels are numbered 0..3). There can be up to 256 devices.
For example:
Device1: 1 0 0 1 (on channels 0, 3)
Device2: 0 1 1 0 (on channels 1, 2)
Device3: 1 1 0 0 (on channels 2, 3)
I need to find a bitmask of channels which will result in the message to be received by a...
This might be a dumb question to some of you and maybe I asked this question wrong, because I am new to c++. But I notice when working in a lot of win32 applications, you use a lot of resources that are pointers. Why do you have to always acquire a objects pointer ? why not initiate a new instance of the class. and speaking of that, I no...
I have an application written in C# that invokes some C code as well. The C# code gets some double as an input, performs some calculations on it, pass it to the native layer that perform its own calculations on it, and then passes back to the C# layer.
If i run the same exe/dlls on different machines (all of them are x64 by Intel), is...
Hi,
I have the following for my HashTable structure:
typedef char *HashKey;
typedef int HashValue;
typedef struct sHashElement {
HashKey key;
HashValue value;
} HashElement;
typedef struct sHashTable {
HashElement *items;
float loadFactor;
} HashTable;
I never really thought about it until now but I just realized th...
I want to make a list of global variables/macros consumed by a function and output by the function. For example, for:
void myfn(void) {
out1 = in + 1;
out2 = 2;
}
..the tool would list the inputs as 'in' and the outputs as 'out1' and 'out2'.
Does anyone know of such a tool?
...
i have to do something like this in C but it works only if I use a char but I need a string
how can I do?
#define USER "jack" // jack or queen
#if USER == "jack"
#define USER_VS "queen"
#elif USER == "queen"
#define USER_VS "jack"
#endif
thanks to all!
...
In the data structures class that I am currently taking, we have been tasked with writing a web crawler in C++. To give us a head start, the professor provided us with a program to get the source from a given URL and a simple HTML parser to strip the tags out. The main function for this program accepts arguments and so uses argc/argv. Th...
After reading the mkdir(2) man page for the Unix system call with that name, it appears that the call doesn't create intermediate directories in a path, only the last directory in the path. Is there any way (or other function) to create all the directories in the path without resorting to manually parsing my directory string and individu...
From a question on the Practice C test from GeekInterview, why is the size of ptr1 2, while ptr2 and ptr3 are size of 4?
main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}
Output: 2 4 4
...
This question was asked to me in an interview.
Suppose char *p=malloc(n) assigns more than n,say N bytes of memory are allocated and free(p) is used to free the memory allocated to p.
can heap manager perform such faulty allocation ?
what happens now, will n bytes are freed or N bytes are freed?
is there any method to find how much m...
I am trying to setup my swap chain Buffer but I get the following error
error C2228: left of '.DXGI_MODE' must have class/struct/union
1> type is 'DXGI_MODE_SCANLINE_ORDER'
Note sure what I am doing wrong. here is the code
DXGI_SWAP_CHAIN_DESC swapChainDesc;
// Set the width and height of the buffers in the swap chain
...
Trying to understand answers to my question
http://stackoverflow.com/questions/2336345/what-happens-when-tried-to-free-memory-allocated-by-heap-manager-which-allocates
I wrote this function and puzzled by its output
int main(int argc,char **argv){
char *p,*q;
p=malloc(1);
strcpy(p,"01234556789abcdefghijklmnopqrstuvwxyz"); //si...
I'm not sure what the "general" name of something like this might be. I'm looking for a library that gives me a file format to store different types of binary data in an expanding single file.
open source, non-GPL (LGPL ok)
C interface
the file format is a single file
multiple files within using a POSIX-like file API (or multiple "blob...
In beej's guide to networking there is a section of marshalling or packing data for Serialization where he describes various functions for packing and unpacking data (int,float,double ..etc).
It is easier to use union(similar can be defined for float and double) as defined below and transmit integer.pack as packed version of integer.i, ...