First a little background ...
In what follows, I use C,C++ and Java for coding (general) algorithms, not gui's and fancy program's with interfaces, but simple command line algorithms and libraries.
I started out learning about programming in Java. I got pretty good with Java and I learned to use the Java containers a lot as they tend t...
I'm trying to write a function that takes a stream as an argument and reads from that stream and reads in the contents of the file up to the first whitespace as defined by the isspace function, and then uses the strtok function to parse the string. I'm not sure how to start it though with which function to read a line and ignore the whi...
void main()
{
void *v;
int integer=2;
int *i=&integer;
v=i;
printf("%d",(int*)*v);
}
this simple program will result in a compiler error saying:
Compiler Error. We cannot apply indirection on type void*
what exact does this error mean?
...
//include all necessary header files
Void Main()
{
float a;
b=square(a);
}
int square(float a )
{
int y;
y=a*a;
return(a);
}
When i makes argument int type then it is working.
Please do not define prototype or write function over main.
Tell Me logic why this gives error.
...
I've been trying to figure out pointers in C most of today, even asked a question earlier, but now I'm stuck on something else. I've got the following code:
typedef struct listnode *Node;
typedef struct listnode {
void *data;
Node next;
Node previous;
} Listnode;
typedef struct listhead *LIST;
typedef struct listhead {
...
Interesting little bug here:
if (host != NULL) {
printf("hi");
} else {
printf("FAIL");
}
return 0;
doesn't print anything at all, but:
if (host != NULL) {
printf("hi");
} else {
printf("FAIL");
}
fprintf(stdout, "\n%s\n", (char *)&additionalargs);
return 0;
prints
hi
abc
Does anyone know why this is?...
Ok so I don't get how to writer this function it simply takes a scalar and multiplies it by the matrix, but I don't get how to call it on or anything.
I have created the Matrix:
MX* mxCreate(unsigned int height, unsigned int width) {
int i = 0;
double** mxPtr;
mxPtr = (double**)malloc(sizeof(double*) * height);
ASSERT(m...
I'm working on getting a CUDA application to also monitor the GPU's core temp. That information is accessible via NVAPI.
A problem is that I want to make sure I'm monitoring the same GPU as I'm running my code on.
However, there seems to be information suggesting that the device IDs I get from NvAPI_EnumPhysicalGPUs does not correspond...
I want to print out (or otherwise ascertain) the type of some variable in my program. Is there a good way to do it? By good, I mean a way that works, even if it means intentionally throwing compiler errors.
For example:
client.c:55: error: incompatible types in assignment
is the error I'm getting right now. What I WANT is it to te...
I have areas of memory that could be considered "array of bits". They are equivalent to
unsigned char arr[256];
But it would be better thought of as
bit arr[2048];
I'm accessing separate bits from it with
#define GETBIT(x,in) ((in)[ ((x)/8) ] & 1<<(7-((x)%8)))
but I do it a lot in many places of the code, often in performance-...
I am trying to get cracking with my C module at uni, however I can't seem to get an IDE to work. I want to use Visual Studio though I guess I should be using Unix (I just don't understand Unix enough yet).
How in Visual Studio 2008 do I set up a project to work with C? I have used Visual Studio for VB.net before and it was a doddle to u...
I'm using the fgets function to read a line from a file. I don't understand how to ignore the leading whitespace of a file though. I thought if I had a char array I could check the first value to see if it is whitespace with isspace, and then increment to the next value. My code looks like:
while (!feof(fp)) {
fgets(str, LINE...
Hi,
I added some additional code to the Linux kernel (the scheduler)
and now I would like to know what is the impact of this modification.
For user processes I always used:
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, ...);
Now I am wondering if there is a kernel-equivalent routine that I could
use to do something similar.
Many thanks ...
#include <stdio.h>
int main()
{
int a = 4;
int b = 3;
addNumbers(a, b);
}
int addNumbers(int a, int b)
{
return a + b;
}
Why does this not compile, I get a message saying implicit declaration of function addNumbers()?
...
Hi all,
i have strings like "folder1/file1.txt" or "foldername1/hello.txt" and i need to take the substring that identify the folder name with the slash (/) included (example: from "folder1/file1.txt" i need "folder1/"). The folders name are not all with the same length.
How can i do this in C?? thanks
...
Older versions of gcc (for example 4.0.2 or 4.1.2) had the option -df (see http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Debugging-Options.html#index-fdump_002drtl_002dcfg-357). I used this option to dump the files filename.c.134r.life2 and filename.c.126r.life1, because I want to extract some values out of these files (for example the reg...
Hello all
I am receiving some encrypted data on a S/MIME message (not an e-mail, but SOAP request over SSL) and I need to get it out of the package.
Does anyone know of any C/C++ interface to do it?
I need something that just strips the SMIME headers and leaves me with the enveloped data, which I would then decrypt to get the MIME ...
Is there a one-liner that lets me output the current value of an enum?
...
Hi i want to see implementation of java.util.zip.CRC32. But within this class its using native c library functions for core implementation.How can I get the native source code. I can see the java.util.zip.CRC32 source code, but this doesn't have the actual implementation.
...
enum Month {January, February, March, April, May, June, July,
August, September, October, November, December};
enum ShortMonth {Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};
May is a common element in both enums, so the compiler says redeclaration of enumerator `mei'. Why? And how can I circumvent this?
...