On my computer programming class in college, we were asked to create a Java program to read and store various elements on a list.
Storing is not a problem, but I'm having some issues regarding the reading of the values. I'm using "variable = input.nextLine();" (if the variable is String), and the problem is that when I read several valu...
Hey Guys
I have a simple wrapper for an Mersenne twister random number generator. The purpose is to scale the number returned by the generator (between 0 and 1) to between argument defined limits (begin and end).
So my function is
inline float xlRandomFloat(float begin, float end) {return (begin+((end-begin)*genrand_real2()));}
I ...
I have the following piece of code:
void TestFunc(const void * const Var1, const float Var2)
{
*(float*)Var1 = Var2;
}
It looks like I am changing the value of the const object the const pointer points to (thanks sharptooth), which should not be allowed. Fact is, none of the compilers I tried issued a warning. How is this possible?...
I dont understand why my code does not work.
This is my code. I don't know why I'm get an error segment. Could somebody explain the reason to me?
#include <iostream>
#include <string>
#include <sys/types.h>
#include <unistd.h>
int id_process;
void manager_signal () {
kill (id_process, SIGKILL);
kill (getppid(),SIGKILL);
}
in...
I am trying to implement JSR 257 ("Contactless Communication API") API and required to use C programming language. I am wondering if anyone knows of similar C API available so one can use as a basis. What would be a best approach to do this? I am thinking of going ahead and starting to design/implement one but do not want to re-invent if...
I would like to port an embedded application to x86 to create an emulator.
We decided to give VS2008 a try but I'm not sure how to make vs to understand our existing directory structure:
arch/
arch/hcs08 -- HAL implementation
arch/include -- public interface of HAL
arch/x86 -- here should goes the emulation layer
os/
os/src -- sour...
Hello,
I've got two jobs offerings - C programmer (for middle-sized company) and ASP.NET/C# programmer (for starup company). Salary is the same. Which one would you choose and why? I mean what would be better for future carrer, for future job-hunting, etc.
I've been learning java for some months and would like to work as a java develop...
I have a assembly file and a c file compiled to .o files (start.o and main.o) and is trying to link them with ld. I'm using this command:
ld -T link.ld -o kernel.bin start.o main.o
where link.ld is a linker script, but when I run it, i get this error:
start.o:start.o:(.text+0x2d): undefined reference to `_main'
in the assembly file...
I need to write data to a binary file using C's I/O functions. The following code causes a runtime exception :
#include "stdio.h"
int main(int argc,char* argv[]) {
FILE *fp = fopen("path_to_file.bin","wb");
if(fp == NULL) {
printf("error creating file");
return -1;
}
int val = 4;
fwrite((const void*)val,s...
A c/c++ app throws that error, how to start to debug (better idea than adding print statements)?
...
I have to implement an algorithm to decompose 3D volumes in voxels. The algorithm starts by identifying which vertexes is on each side of the cut plan and in a second step which edge traverse the cutting plan.
This process could be optimized by using the benefit of sorted list. Identifying the split point is O log(n). But I have to mai...
I want to be able to read the content of pdf files. I need to do that with C on Linux.
The closer i can get to this was here but I think Haru can only create pdf and is not able to read them (not 100% sure).
PS: I only need the plain text from pdf
...
This question is a lazy way of collecting examples of parsing HTML with a variety of languages and parsing libraries. Individual comments will be linked to in answers to questions about how to parse HTML with regexes as a way of showing the right way to do things (similar to how I use Can you provide some examples of why it is hard to p...
This is such a dumb question it's frustrating even asking it. Please, bear with me, I'm feeling particularly dumb over this one today....
I've got a library with a certain typedef struct. basically:
typedef struct {int x; int y;} coords;
What I really wanted to do was declare in my header a variable array of this:
coords MyCoord...
I am using MiniLZO on a project for some really simple compression tasks. I am compressing with one program, and decompressing with another. I'd like to know how much space to allocate for the decompression buffer. I am fine with over-allocating space, if it can save me the trouble of having to annotate my output file with an integer ...
I have this problem to solve that I have no idea how to do it because there's only a few system calls we can use to solve it and I don't see how they are helpful for the situation.
The Exercise:
I have matrix with size [10][1000000] with integers and for each line I create a new process with fork(). The idea of each process is to go thr...
Unix has \n, Mac was \r but is now \n and DOS/Win32 is \r\n. When creating a text file with C, how to ensure whichever end of line character(s) is appropriate to the OS gets used?
...
In my copy of C Programming Language (aka: K&R), there seems no mention of multithreading. Is the book less complete than I imagined? Did multithreading emerge after it was written? Am I thinking about this the wrong way?
Where does the concept of multithreading fit into the C world?
Edit: I think my original question have been:
yo...
For those who know or are learning C: Why did you choose to learn C?
Was a school or job requirement? Curiosity? Boredom? Personal growth? ...
I'm especially curious to know how many learned it to better understand the inner workings of their language of choice. If this is your reason, was it prompted by Joel's suggestions?
...
I am using the sqlite3.c library.
It compiles with 140 something conversion warnings.
What's wrong with my set-up?
Thanks.
sqlite3.c
c:\Projects\Lib\sqlite3.c(11311) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
c:\Projects\Lib\sqlite3.c(11312) : warning C4244: '=' : conversion from 'double' to 'in...