Hi guys!
I must write array of struct Data to hard disk:
struct Data {
char cmember;
/* padding bytes */
int imember;
};
AFAIK, most of compilers will add some padding bytes between cmember and imember members of Data, but I want save to file only actual data (without paddings).
I have next code for saving Datas array (in ...
It's been 10 years since I looked at c. I need to write a little program in c that parses a string. I wanted to use regular expressions since I've been using them for years, but I have no idea how to do that in c. I've spent the morning Googling and I can't find any straight forward examples (ie. use this library, this is the methodol...
I've got a double... say
double d = 25.342;
How can I get the 25 value? ( If it were -12.46 I'd like to get -13)
Thanks!
Manuel
...
#include<stdio.h>
int main()
{
float a=5;
printf("%d",a);
return 0;
}
This gives the output:
0
Why is the output zero?
...
A simpler life
I am returning to C to help reinvigorate my programming lobe. The last time I learned to program I was at college working with Turbo C on MSDOS. Simple ASCII animations became an obsession once I found Borland's friendly <conio.h> one include away. A lot of fun was had with the gotoxy and textcolor functions and it wasn...
From C++, are min and max preferable over fmin and fmax? For comparing two integers, do they provide basically the same functionality?
Do you tend to use one of these sets of functions or do you prefer to write your own (perhaps to improve efficiency, portability, flexibility, etc.)?
Notes:
The C++ Standard Template Library (STL) d...
Hello,
I'm trying to compile the zpipe.c example in my Linux(Ubuntu 8.04) with gcc, but I'm getting some errors, take a look:
[ubuntu@eeepc:~/Desktop] gcc zpipe.c
/tmp/ccczEQxz.o: In function `def':
zpipe.c:(.text+0x65): undefined reference to `deflateInit_'
zpipe.c:(.text+0xd3): undefined reference to `deflateEnd'
zpipe.c:(.text+0x150...
I have this Viterbi Decoder function code, which is quite lengthy and there are no comments labeling to help, and I want to try to understand it.
So anyone can point me to an easy to understand algorithm?
Anyway, here is the code:
int viterbiDecode( int nBit, float *p_pm, int *p_sp, int *p_bStore, float *p_hd, int TB, int fc, int lc, ...
I'm trying to streamline large chunk of legacy C code in which, even today, before doing the build guy who maintains it takes a source file(s) and manually modifies the following section before the compilation based on the various types of environment.
The example follows but here's the question. I'm rusty on my C but I do recall that ...
How do I ignore case when using pcre_compile and pcre_exec?
pcre_exec(
pcre_compile(pattern,0,&error,&erroroffset,0),
0, string, strlen(string), 0, 0, ovector, sizeof(ovector));
what option do i use and where do i specify it?
...
I am trying to use ctags with VIM, and I am a newbie to both. In order to test the extent to which ctags could be useful I decided to put it through a very simple test, namely to parse the headers in /usr/include so that I could autocomplete some very basic functions.
When I run the command
ctags --c++-kinds=+p --fields=+iaS -f ~/.ta...
Hello,
According to the Linux man page for mprotect the function has 3 Arguments:
int mprotect(const void *addr, size_t len, int prot);
but while running ltrace on a program that I'm analyzing I see that mprotect is called like this:
mprotect(0x8049000, 4096, 3, 1, 0xb7e057ac) = 0
what are the 4th and 5th argument for??
Edit...
GCC's recent support for atomic operations (as described here) is great, and is 90% of what we need. Unfortunately, some of our products still need to run on Windows and so we need atomic integer operations for Windows as well.
In the past, we had custom assembly language implementations for all our platforms, but I'd like move all the...
In comments in source code (especially older code), one may see in the header comments the filename, date and perhaps other info in this special format:
/* @(#)fdlibm.h 1.5 95/01/18 */
(see also: http://www.google.com/codesearch?q=%22%40%28%23%29%22&hl=en&btnG=Search+Code )
This is quite similar (or perhaps related?) to the RC...
I've got two signed integers, and i'd like to subtract them. I need to know if it overflowed.
int one;
int two;
int result = two-one;
if (OVERFLOW) {
printf("overflow");
} else {
printf("no overflow");
}
Something like that. Is there a good way to do this?
...
I have the following code:
gcc test.c -o test -D ARGUMENT 2
and I want it to define ARGUMENT with a value of 2 but it says cannot find file 2 or something. How do I do this?
...
Hello,
Do you know why a lot of file are not listed by this program, even if they are "regular"?
#include <stdio.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>
int main(void) {
DIR *dh = opendir("./"); // directory handle
struct dirent *file; // a 'directory entity' AKA file
struct...
I have some ANSI C code that I developed on my Mac, but when I tried running it on our school's Linux servers I get a segfault.
The specific line that is causing me trouble is a getc from a file pointer.
The file does exist.
Here is the method in question:
// inits lists with all data in fp file pointer
// returns # of lines read
int...
int length = strlen(src);
char *structSpace = malloc(sizeof(String) + length + 1);
String *string = (String*) structSpace;
int *string = (int*) structSpace;
*I created a struct called String
...
Hello,
My friend have real Macintosh IIci, that uses Mac System 7.5.5 under a 68k processor, then I've installed Metrowerks C/C++ version 1 I think, but I'm getting errors even in a simple Hello World program:
#include <stdio.h>
int main(void)
{
printf("Hello, World!");
return 0;
}
I'm getting this error:
·· Link Error : Li...