C is a general-purpose computer programming language used for operating systems, games and other high performance work.

learn more… | top users | synonyms

0
votes
0answers
7 views

Defining property and find substitution for copy function of python in cython

I want to cythonize a code in python to speed up the code. In the following you can see my attempt to make my python class understandable for cython: import numpy as np cimport numpy as np ctypedef ...
-7
votes
0answers
97 views

SOLVED! Error in result: 5^2 = 24 and 10^2 = 99? [on hold]

The compiler is GCC and the program Codelite. Using double or float works!
9
votes
4answers
945 views

Pointer indexing

I am currently reading a book titled "Numerical Recipes in C". In this book, the author details how certain algorithms inherently work better if we had indices starting with 1 (I don't entirely follow ...
-5
votes
0answers
54 views

How to become malware analyst [on hold]

I am willing to be a malware analyst. I am 17 years old and want to be guided. I tried learning x86 assembly form (the art of assembly) but it was complex and I believe that it is very old (I don't ...
-1
votes
0answers
141 views

Picking a language for writing code [on hold]

I'm in a situation, which I guess would've been encountered by all professional programmers at some point. For the same of rapid development, I chose to write modules in python. Soon, in our perf ...
0
votes
0answers
40 views

How does the android JNI work [on hold]

I am currently trying to create an iPhone/android app I have chosen to write the model of my program in C++ since it is supported by both platforms. I have been able to compile my C++ source into the ...
-2
votes
1answer
94 views

How can we make a certain thing inbuilt in c language with our own header file?

I want to make the basic trigonometric functions in maths inbuilt functions using my own header file . so as the users can do trigonometry in c language compilers.
2
votes
0answers
148 views

What's wrong with this pointer? [migrated]

I though I had finally understood pointers but then I encountered this issue: typedef struct { unsigned int a; unsigned int b; } Bar; Bar *foo; foo->a = 3; This last instruction ...
1
vote
2answers
66 views

How to handle enums in an indirection with functionpointers at ANSI-C?

Moinsen, I am somehow stucked in a design problem. Language is ANSI-C. Lets assume we have a tinkerbox of software-modules: one module for the logic Logic (at least) one module doing some logging ...
-5
votes
0answers
27 views

Using Eclipse CDT tools for C/C++ — How to use interactive runtime for programs? [closed]

For the code below, I had expected it to go line by line but the output received is all at a time i.e, when I run it after building I pass ib the input in the first line and receive result next to it ...
16
votes
4answers
515 views

How bad is it calling println() often than concatenating strings together and calling it once?

I know output to the console is a costly operation. In the interest of code readability sometimes it is nice to call a function to output text twice, rather than having a long string of text as an ...
2
votes
4answers
1k views

Going through The C Programming Language K&R in Visual Studio

From what I have read, K&R seems to be a good place to start learning programming in general, and C programming specifically. However, I've just started the first chapter and I have a few ...
-1
votes
1answer
102 views

Programmer Analyst vs Software Engineer [closed]

So I've heard the job title "programmer analyst" and "business analyst" thrown around for software jobs recently. How do the responsibilities of Programmer Analysts, Business Analysts and Software ...
-2
votes
0answers
71 views

How can I improve the following code in terms of faster execution? [migrated]

The problem is described here - Aaah!. My source code for the problem is below. I one of the fast running codes, but not the best. What changes can I make so as to improve the efficiency of the code. ...
1
vote
4answers
570 views

Why would a C executable be smaller when compared to C++ executable

I'm trying to understand why the output file sizes are significantly different when using a C and a C++ compiler. I was writing a small hello world program in C and C++, I noticed that in C version, ...
0
votes
3answers
127 views

usage of double pointers and n pointers?

I am familiar with basic C pointers. Just wanted to ask what is the actual use of double pointers or for that matter n pointer? #include<stdio.h> int main() { int n = 10 , *ptr , **ptr_ptr ; ...
0
votes
0answers
4 views

What happens when there is multiple expressions in the condition part of a for loop seperated by commas? [migrated]

I have an infinite loop here, but why? int end = 5; for(int i = 0; i < end, printf("at condition i=%d\n",i); ++i) { printf("inside i=%d\n",i); }
6
votes
1answer
212 views

Suggested method for extracting a standalone C library from an existing R package?

My group has been developing an R package to simulate plant growth (see GitHub repository). The R package uses .Call to interface with C. We have decided that it would be worthwhile to create a ...
0
votes
0answers
74 views

Different ways of addressing pointers C/C++ [migrated]

I'm a little confused about accessing specific addresses using c style pointers. I have a 32 bit chip which I'm tryin to program. I need to flip some bits or whatever in ram. The following solution ...
2
votes
3answers
234 views

Transitioning from Java & C to C++

I learned Java and I'm pretty competent programming in it. I also learned C recently. I looked at a comparison between Java and C++ and I like C++'s features like operator overloading and its speed. ...
2
votes
3answers
269 views

Understanding how variable assignment works

When I started learning C programming a few years ago, my tutor taught me similar to most of the tutors around the world. She said me the very basic things like any int datatype is of 2 bytes memory. ...
1
vote
2answers
143 views

Understanding Arithmetic In C

I have an embarrassingly simple question, but I need to make sure I understand this correctly. I have a *.c file with the following line: CSRConstant = ...
9
votes
2answers
581 views

Why can't arrays be passed as function arguments in C?

Following this comment, I've tried to google why, but my google-fu failed. Comment from link: [...] But the important thing is that arrays and pointers are different things in C. Assuming ...
2
votes
1answer
47 views

gcc -S seems a bit misshapen with shifting and ANDing bits

Example: int c = 4; int p = 5; if (p & (1 << c)) printf("ok\n"); else printf("nop\n"); gcc -S: movl -4(%rbp), %eax /* eax holds the variable c */ movl -8(%rbp), %edx /* ...
0
votes
3answers
139 views

Use of malloc in C

Is it necessary to call free function every time we use malloc in C. I am asking this because I have seen many times that it is not called . Thank you
1
vote
1answer
73 views

How to check the space complexity of this program?

I have written my version of strstr function in c. I am using a temporary array of size 26. Then is the space complexity O(1) or O(n)? This is my code : void strcheck(char t[], int n, char p[], int ...
0
votes
2answers
246 views

Why is it called a memory leak?

I am a hobbyist programmer, bit of a stickler for terminology, currently learning C and recently came across the concept of Memory Leak. Now, I do understand what it means. Dynamic memory allocated to ...
1
vote
1answer
100 views

Memory read/write access efficiency

I've heard conflicting information from different sources, and I'm not really sure which one to believe. As such, I'll post what I understand and ask for corrections. Let's say I want to use a 2D ...
0
votes
1answer
93 views

Global variable in a Linux shared library

Suppose we have the following setup under Linux, .so library named "libcnt.so" and 3 user space apps: "app1", "app2", "app3". This library does 1 simple thing, it says to the app (app dynamically ...
4
votes
1answer
247 views

Why is the function called lseek(), not seek()?

The C function for seeking in a file is called lseek(). Why ins't it called just seek()?
3
votes
3answers
154 views

Organization of DLL linked functions

This is a code organization question. I got my basic code working but when I expand it, it will be terrible. I have a DLL which I don't have a .lib for. Therefore I have to use the whole ...
0
votes
0answers
65 views

Parsing mathematical experssions with two values that have parentheses and minus signs

I'm trying to parse equations like the ones below, which only have two values or the square root of a certain value, from a text file: 100+100 -100-100 -(100)+(-100) sqrt(100) by the minus ...
1
vote
1answer
183 views

Are there theoretical reasons why arrays in C take less RAM than Java?

My experience is that Java requires about twice as much RAM compared to C (comparing char arrays or other comparisons). I also read in a hardware book that Java takes about twice RAM than C. Is is ...
2
votes
3answers
160 views

Why are there two different kinds of linking, i.e. static and dynamic?

I've been bitten for the n-th time now by a library mismatch between a build and deployment environment. The build environment had libruby.so.2.0 and the deployment environment had libruby.a. One ruby ...
4
votes
1answer
534 views

Why are most GNU's software written in C [closed]

I am a Java developer, and I rarely write GUI program in C. However, I noticed that many GNU's projects, such as PSPP, R, Dia, etc., are written in C, instead of Java or C++. I personally don't mind ...
-2
votes
4answers
198 views

Benefits of porting C library to C++ [closed]

Say we take any C library such as libpng or libvorbis and convert it so that it compiles as C++ (only the minimum changes to make it compile as C++ code). Can the compiler do extra optimizations when ...
1
vote
2answers
303 views

“bug” in C++11 text by Stroustrup?

I found an apparent contradiction in the c++ text having to do with the result of the c_str() function operating on std:strings (in my copy, the definition and contradiction are on p1040). First it ...
1
vote
1answer
116 views

Should I implement a function or a method?

Once in a while I encounter a C function in my colleagues' code. Mostly it is in some helpful objective categories, and those functions are mostly an internal calculation of something or a ...
0
votes
3answers
124 views

How are negative signed values stored? [duplicate]

I was watching this video on the maximum and minimum values of signed integers. Take an example of a positive signed value - 0000 0001 The first bit denotes that the number is positive and the last ...
15
votes
1answer
543 views

How to effectively cooperate in a team having mixed background/mindset regarding OOP? [duplicate]

I've been recently assigned for a new high-performance C++ project (finance) together with 3 other guys who, like, me, refer to themselves as "primarily C/C++ programmers", meaning, all of us have ...
20
votes
7answers
3k views

Writing in C for Performance? [closed]

I know I have quite frequently heard that C typically has a performance advantage over C++. I didn't really think anything else of it until I realized that MSVC doesn't even seem to support the newest ...
0
votes
3answers
170 views

comparison of floating point numbers vs. comparsion of Integers in C [closed]

Does comparison of floating point numbers takes (considerably) longer time than comparison of Integers in C? I just wrote a C program of heap sort to sort floating point numbers. I am on ubuntu ...
3
votes
3answers
100 views

Is allocating objects from a memory-pool a security anti-pattern?

In the wake of the heartbleed bug, OpenSSL has been rightly critizised for using its own freelist. With plain-old malloc, the bug would have almost certainly been found long ago. However, some kind ...
0
votes
0answers
18 views

how to find average bits per symbol using huffman code? [duplicate]

I'm trying to write a program in c for Huffman coding, but i stack.In input i have: Sample input: 4 //here i scan how many letters i have A 00 // and for everyone i scan how they are coded in ...
55
votes
10answers
6k views

Why do C arrays not keep track of their length?

What was the reasoning behind not explicitly storing an array's length with an array in C? The way I see it, there are overwhelming reasons to do so but not very many in support of the standard ...
1
vote
0answers
106 views

using flat file vs sqlite db for frequent data grabbing in a cron job

I have some automated task to be done using certain types of logs generated on the server end of each day. Log files contains specific machine identification "MAC" that is to be re-written in to ...
1
vote
1answer
134 views

How to implement an algorithm out-of-core?

I want to implement a parallel clustering algorithm "out-of-core" in CUDA. My CPU has 12GB of RAM and GPU has 4GB of it. What I want is that the entire dataset should be on the disk, and I can pick ...
5
votes
1answer
161 views

At ping, why do we have to do array copying instead of passing on the source array that the client sent to us?

So I have been googling about this OpenSSL heart-bleed thing and somehow sees that it is caused by the heartbeat extension which requires client to ping the server to show its aliveness and it all ...
3
votes
2answers
102 views

Advice for simple communication protocol (iPod and Arduino)

I connected iPod with Arduino using serial (UART) connection. Arduino sends 0-1023 number (so it's two bytes) as it's samples light sensor value. I'm asking about advice about simple and reliable ...
3
votes
2answers
157 views

How to manage memory in C interface for C++ implementation considering c++11?

I have a library implemented in C++ which has a C interface. This C interface is, for all intents and purposes, the only way to use this library. C++11 seems to discourage the use of raw pointers but ...