I have a function call in a program that I'm maintaining has 28 arguments for a printf call. It's printing a lot of data in a CSV file. I have problems following finding where what goes and I have some mismatches in the parameters types. I enabled -Wall in gcc and I get warnings like:
n.c:495: warning: int format, pointer arg (arg 15)
n...
Hi all,
I'd like to determine the environment's current codepage at runtime from a Unix shell script. What's the most reliable way of doing this?
I'm looking into parsing environment variable $LC_ALL, but it isn't always set to a useful value, and its format seems to vary (can be <locale>, or <locale>.<code page>, or <locale>.<code pag...
NSLog function accepts printf format specifiers.
My question is about %x specifier.
Does this print hex codes as sequence on memory? Or does it have it's own printing sequence style?
unsigned int a = 0x000000FF;
NSLog(@"%x", a);
Results of above code on little or big endian processors are equal or different?
And how about NSString's -...
After learning that both strncmp is not what it seems to be and strlcpy not being available on my operating system (Linux), I figured I could try and write it myself.
I found a quote from Ulrich Drepper, the libc maintainer, who posted an alternative to strlcpy using mempcpy. I don't have mempcpy either, but it's behaviour was easy to r...
Suppose we have the following method (it is in c code):
const char *bitap_search(const char *text, const char *pattern)
My question is how can I compare text and pattern if they are char? This method is like a substring problem but I am confused a bit can I write in term of char such code?
if (text[i]==pattern[i])?
look i am interesti...
Today I discovered alarming behavior when experimenting with bit fields. For the sake of discussion and simplicity, here's an example program:
#include <stdio.h>
struct Node
{
int a:16 __attribute__ ((packed));
int b:16 __attribute__ ((packed));
unsigned int c:27 __attribute__ ((packed));
unsigned int d:3 __attribute__ ((packe...
I am a beginning C programmer (though not a beginning programmer) looking to dive into a project to teach myself C. My project is music-based, and because of this I am curious whether there are any 'best practices' per-se, when it comes to timing functions.
Just to clarify, my project is pretty much an attempt to build some barebones m...
I realize this might be a long shot, but does anyone have an example of using the EI-1050 probe with a Labjack controller in something C-related? I'm currently using a Labjack U12 if it matters.
It installed 2 examples, ljsht and ljsht-multi, that seem to be doing something related to it, but I can't find the source code.
Thank you for...
Lets say I have the following:
CHARLINK * _init_link(CHARLINK **link)
{
short i;
(*link)->cl = (CHARLINK **) calloc(NUM_CHARS, sizeof(CHARLINK *));
for (i = 0; i < NUM_CHARS; i++)
(*link)->cl[i] = NULL;
return (*link);
}
Is the loop to initialize each element to NULL necessary or are they automatically NULL ...
i want to know how can one know the functions present in header files in c when running in linux systems
...
I found this regarding how the C preprocessor should handle string literal concatenation (phase 6). However, I can not find anything regarding how this is handled in C++ (does C++ use the C preprocessor?).
The reason I ask is that I have the following:
const char * Foo::encoding = "\0" "1234567890\0abcdefg";
where encoding is a stati...
Oftentimes data structures' valid initialization is to set all members to zero. Even when programming in C++, one may need to interface with an external API for which this is the case.
Is there any practical difference between:
some_struct s;
memset(&s, 0, sizeof(s));
and simply
some_struct s = { 0 };
Do folks find themselves usi...
I need help with malloc() inside another function.
I'm passing a pointer and size to the function from my main() and I would like to allocate memory for that pointer dynamically using malloc() from inside that called function, but what I see is that.... the memory, which is getting allocated, is for the pointer declared within my called...
I recently started a small personal project (RGB value to BGR value conversion program) in C, and I realised that a function that converts from RGB to BGR can not only perform the conversion but also the inversion. Obviously that means I don't really need two functions rgb2bgr and bgr2rgb. However, does it matter whether I use a functi...
For this code:
#include<stdio.h>
void hello() { printf("hello\n"); }
void bye() { printf("bye\n"); }
int main() {
printf("%p\n", hello);
printf("%p\n", bye);
return 0;
}
output on my machine:
0x80483f4
0x8048408
[second address is bigger in value]
on Codepad
0x8048541
0x8048511
[second address is smaller in v...
Both ideone.com and codepad.org have Little-Endian architechtures.
I want to test my code on some machine with Big-Endian architechture (for example - Solaris - which I don't have). Is there some easy way that you know about?
...
I am building a shared library on Ubuntu 9.10. I want to export only a subset of my functions from the library. On the Windows platform, this would be done using a module definition (.def) file which would contain a list of the external and internal names of the functions exported from the library.
I have the following questions:
How ...
I have a server and a client written in C. I try to load a shared library in the server and then pass library function pointers to the client. This way I can change the library without have to compile the client.
Because of every process has its own separate memory space, I wonder if it is possible to load a shared library on a shared m...
Or it's the same in c/c++?
...
It should give me the number of inputs entered by the user. But it gives 100. I compiled with gcc.
#include <stdio.h>
int arr[100];
int count=0;
int max=100;
int main(){
int i, input;
printf("Enter integer values one by one, q to quit.\n");
for(i=0;i<max;i++){
scanf("%d",&input);
arr[i]=input;
if(input=='q')break;
count++;...