Hi
I am using ms c++. I am using struct like
struct header {
unsigned port : 16;
unsigned destport : 16;
unsigned not_used : 7;
unsigned packet_length : 9;
};
struct header HR;
here this value of header i need to put in separate char array.
i did memcpy(&REQUEST[0], &HR, sizeof(H...
I am writing an automatic grader program under linux. There are several graders written in MATLAB, so I want to tie them all together and let students run a program to do an assignment, and have them choose the assignment. I am using a C++ main program, which then has mcc-compiled MATLAB libraries linked to it.
Specifically, my progra...
#include<stdio.h>
#include<conio.h>
union abc
{
int a;
int x;
float g;
};
struct pqr
{
int a;
int x;
float g;
} ;
void main()
{
union abc b;
struct pqr c;
clrscr();
b.a=10;
textbackground(2);
textcolor(6);
cprintf(" A = %d",b.a);
printf("\nUnion = %d",sizeof(b));
printf("\nStructure = %d",sizeof(c));
get...
A company I am working for, has some c binaries build with ant using cpptask. They use ivy to retrieve shared c libraries every time we start a build which wastes a significant amount of time comparing the revisions and downloading, when then only need to be download if the header files have changed. I have added a target which sets a va...
When should I inline a member function and when should I use member initializers?
My code is below.. I would like to modify it so I could make use some inline when appropriate and member initializers:
#include "Books.h"
Book::Book(){
nm = (char*)"";
thck = 0;
wght = 0;
}
Book::Book(const char *name, int thickness, int weight){
...
MSDN documentation seems silent on whether RegCreateKeyEx ever updates the value of the handle referred to by its second-last parameter when it fails. My tests have only shown it not to update this - i.e., I set h = 0 before the call, pass &h to a call to RegCreateKeyEx to open a non-existent key, and see h = 0 after the call. Does anyon...
Hi guys
I m programming C for an assingment in VC++ 2008. I simulate adjList for graph implementation. i can readly add edge between two vertex and print the graph.
and i want to remove edge between two vertex and print the graph again. whatever i do,i cant print the graph after deleting the edge. i get 0xfeefee :( what is this? and...
I am using strdup here to copy the value of the parameter name into nm in the constructor... is there an alternative of achieving the same result without using strdup and without using the C++ STL library and using the keyword new instead?
Book::Book(const char *name, int thickness, int weight):nm(NULL), thck(thickness), wght(weight){
...
Hey everyone,
I am new to C and I am working on an XOR linked list for a project. I have most of the code done, but I can't seem to get the delete function of the list to work properly. It seems able to delete some numbers, but not any number you pass into the function. Could anyone experienced with C take a look and possibly point out w...
My function is being passed a struct containing, among other things, a NULL terminated array of pointers to words making up a command with arguments.
I'm performing a glob match on the list of arguments, to expand them into a full list of files, then I want to replace the passed argument array with the new expanded one.
The globbing is...
Programs on Linux install data for programs into $PREFIX/share/programname, how does the program know where that is, does it need to be compiled in?
Would it be suitable to assume that the binary is in $PREFIX/bin, and use that to determine $PREFIX?
This only needs to work on Linux, and specifically, I am using C.
...
I am stuck on this problem in my homework. I've made it this far and am sure the problem is in my three for loops. The question directly says to use 3 for loops so I know this is probably just a logic error.
#include<stdio.h>
void matMult(int A[][5],int B[][5],int C[][5]);
int printMat_5x5(int A[5][5]);
int main() {
int A[5][5] = {{...
What are the reason/s behind other languages not having a Garbage Collector?
EDIT: Why garbage collection is not built-in for these other languages? why do programmers given the responsibility to collect?
EDIT: All of the questions if possible please :)
...
I'm writing an MPI C program. I have troubles debugging it, because whenever I use fprintf, like this: fprintf(stdout, "worker: %d", worker); if the program hangs, because of some blocking MPI_Recv, I can't see any output. I'm sure the line of code is reached, because I can put a return statement after the fprintf statement, in which cas...
Are there any C/C++ open source audio encoder besides LAME MP3? It doesn't need to be exactly mp3 format, I need a "compressed digital audio file".
I do not want to use Lame because it is too big while no programmer can answer a simple question on it (share simple but easily downloadable and readable project containing only needed 2 sim...
Please see this piece of code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main() {
int i = 0;
FILE *fp;
for(i = 0; i < 100; i++) {
fp = fopen("/*what should go here??*/","w");
//I need to create files with names: file0.txt, file1.txt, file2.txt etc
//i.e. file{i}.txt
}
}
...
Consider the following code which shows compile time error :
#include <stdio.h>
int main(int argc, char** argv)
{
int x=5,y=0,z=2;
int a=z?x,y?x:(y); // but z?x,y?x:y:z is not showing any error
printf("%d",a);
return 0;
}
Please help me explain the reason why z?x,y?x:y:z is not showing any error?
...
i am going to paste here my code an errors ::::
#include "stdio.h"
#include "winsock2.h"
#define SIO_RCVALL _WSAIOW(IOC_VENDOR,1) //this removes the need of mstcpip.h
void StartSniffing (SOCKET Sock); //This will sniff here and there
void ProcessPacket (unsigned char* , int); //This will decide how to digest
void PrintIpHeader (uns...
Yesterday, I have been watching discussion here, about compilers and linkers. It was about C library function definitions. I have never thought of that, so it inspired me to do some searching, but I cannot find exactly what I want. I wonder, what is the smallest syntax you need to add into your source code to enable just printf() functio...
Hi, i asked some time ago on an account i cant remember how to manipulate basic pointers and someone gave me a really good demo
for example
char *ptr = "hello" (hello = a char array)
so now *ptr is pointing at h
ptr++ = moves the ptr to point at the next element, to get its value i do *ptr and that gives me e
ok so far i hope :D ...