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

learn more… | top users | synonyms

-2
votes
0answers
119 views

alternatives to pointer to function in C [on hold]

I have C project where I have something like iterator, works like this: Item *mem_first(MemtableIT *it); Item *mem_next(MemtableIT *it); and Item *disk_first(DisktableIT *it); Item ...
-6
votes
0answers
39 views

Does microsoft prefers visual languages in his competition [on hold]

I’m confused about which language to prefer? I know C, C++, VB.NET basics I’m participating in a competition of Microsoft so should I prepare my vb.net or I should consist c/c++ Please Help me out ...
0
votes
1answer
223 views

Understanding the solution of Exercise 1.12 of K&R's book as given in the book “The C Answer Book”

I am reading the solution of "The C Answer Book". I think that the solution of Ex. 1.12 can be shortened. The Exercise is as, Write a program that prints its input one word per line. The ...
0
votes
2answers
82 views

forking but not exiting

It is normal for the child in a fork() to call exec() or _exit(). Are there any realistic scenarios where the child might return from the function that called fork() instead? void foo() { pid_t ...
-1
votes
0answers
18 views

Closing Nonduplex Unnamed Pipes in C [migrated]

I have 8 children, and am trying to use 8 pairs of nonduplex unnamed pipes to communicate with them. Thus, I have 2 pipes for each child and 16 pipes in total (one for childRead_ParentWrite and the ...
0
votes
0answers
52 views

Use of SAL annotations for C++ [on hold]

Code analysis tool for visual studio is able to detect some kinds of errors statically if you annotate functions with SAL We used it at first in windows driver when code was mostly C code, and where ...
-6
votes
1answer
63 views

in c programming i need custom atoi code [on hold]

i want to subtract two 64 bit hex numbers(in c programming), 0x0000888888888888 -1st hex value - 0x00000000839DDB7A -2nd hex value = 0x0000888804EAAD0E =(need the above result in hex) The 1st ...
1
vote
3answers
209 views

Alternative to goto-statement in this case? [duplicate]

Currently I am using gotos for closing handles and general cleanup if an error occurs. Since I don't want to nest all the ifs and a function for cleanup would require a return besides the cleanup(); ...
6
votes
2answers
1k views

Why is C still in the category of High Level Language? [closed]

Many of the textbooks on the C programming language tell that C is a high-level programming language, but many of the tutors online say that C is also a middle-level programming language. Why is it ...
-1
votes
0answers
16 views

How to pause for a second in a C program? [migrated]

I'm creating a simple C program which prints to the console and I want to have the program pause between printing, to create an aesthetic "..." slow printing effect, to make it appear as if it is ...
-5
votes
0answers
81 views

What are the basics of software engeneering [closed]

I want to be a software engineer what is the process where to start I want everything to be online.
-5
votes
0answers
36 views

Help in C! get userinput then display! [closed]

You wanna get info from user function to collect one current, and number of resistors, and each resistance value function to display as below -resistance is not an integer, round up to 3 decimals ...
55
votes
5answers
11k views

Why are there so few C compilers?

C is one of the most widely-used languages in the world. It accounts for a huge proportion of existing code and continues to be used for a vast amount of new code. It's beloved by its users, it's so ...
0
votes
1answer
43 views

Printing an geomterical object/structure and determining the mid point of the two lines passing through it

I am very basic in C programming, may be printing a variable or so. Can any one of you can help me to give me a example code or guide me how to construct an object and determine its mid point? Or to ...
-6
votes
0answers
37 views

Spoj Trie Problem [closed]

Recently I've tried to solve a problem of SPOj. After submitting the solution it is giving me WA. :( I've tried with some cases and every input is giving me correct answer. But as the online judge ...
-1
votes
0answers
14 views

Difference between (int*) calloc and just calloc? [migrated]

What is the difference between: int *array; array = (int*) calloc(5, sizeof(int)); and int *array; array = calloc(5, sizeof(int)); I don't get it. Both samples work. At the university the ...
2
votes
2answers
80 views

Function naming design in a C Library

I'm writing a C (c99) library that operates on strings. I'm having a design problem writing functions that will perform in different modes. For example; the Find function can search for: the ...
-4
votes
0answers
39 views

How can I create a program which records how much internet data is used by each website visited? [closed]

I don't believe this is even possible but it's worth asking, I would like to create a batch file that when run, it will record all IP addresses or URL's visited during an internet session. It won't ...
0
votes
0answers
4 views

C error: parameter has incomplete type [migrated]

I am a relatively new C programmer, so please bear with my ignorance :-) I am trying to get a custom tool for valgrind to compile. The tool was originally written about 8 years ago, and was based on a ...
5
votes
5answers
3k views

Is it better to use preprocessor directive or if(constant) statement?

Let's say we have a codebase that is used for many different costumers, and we have some code in it that is relevant only for costumers of type X. Is it better to use preprocessor directives to ...
-3
votes
1answer
36 views

Passing Parameters to pthread_create [closed]

I have a structure named graph. graph *G; Now I create memory of size of structure using malloc and the start pointer is stored in pointer G. G = (graph*)malloc(sizeof(graph)); My question is ...
4
votes
1answer
194 views

Should I always return an error code from C functions?

I have the following code in many places in a large application: if (datastruct.data_ok && cur_time > datastruct.start_time && cur_time < datastruct.end_time) { ...
1
vote
2answers
472 views

Is there a better way to organize my module tests that avoids an explosion of new source files?

I've got a neat (so I thought) way of having each of my modules produce a unit-test executable if compiled with the -DTESTMODULE flag. This flag guards a main() function that can access all static ...
12
votes
5answers
2k views

Advice for an ambitious student on building your own kernel [closed]

I'm a very ambitious university student who wishes to learn pretty much everything there is to know about computers (bash me if you want, I love learning). Recently I thought it would be a fun project ...
0
votes
0answers
53 views

Writing Z80 table based assembler/disassembler

I have a long-term project: DIY computer with various processors. One of my wishes not only make hardware, but software too. So I started from assembler/disassembler for Linux, though there is a lot ...
-1
votes
0answers
11 views

Printing calculator- stephen kochan programming in C question [migrated]

I'm a newbie at programming, just one month into C. Working with stephen kochan's programming in C. There is a question in chapter 6 to write a printing calculator where 's' tell the program to set ...
0
votes
1answer
126 views

Can i create a function with variable parameters in C?

I've always wondered where a single function such as printf(); can take in variable parameters and provide the right results. For example, printf("Number is %d",a); which has two parameters, and ...
16
votes
9answers
3k views

Can you “stop” a C program from being reverse engineered? [duplicate]

I'm sure that many of the middle to high level languages can be reverse engineered. But if a C program can be reverse-engineered, and turned back into editable source code, how do I discourage such a ...
0
votes
2answers
927 views

Assigning strings to pointer in C Language

I am a new learner of C language, my question is about pointers. As far i learned and searched pointers can only store addresses of other variables, but cannot store the actual values(like integers or ...
1
vote
3answers
100 views

Will C compiler attach the whole object code of the header file?

When you compile a C source code does the compiler convert the whole header file to object code or just the functions of the header file you use? Like for example, in the header file #include ...
-1
votes
0answers
10 views

escaping a complete packet read in apache module [migrated]

According to this site: http://pedrowa.weba.sk/docs/ApiDoc/apidoc_ap_get_client_block.html This function: ap_get_client_block(request_rec *r, char *buffer, int bufsiz); Reads a chunk of POST ...
1
vote
2answers
130 views

In C, what is an unconditional jump?

I have to fill out some documentation regarding a C project i worked on. One topic is whether I used "unconditional jumps". As far as I know, a "break" statement counts as a jump. And I have a few of ...
2
votes
2answers
90 views

Returning multiple values from a c function using pointers; style of parameter list

What is good programming style for writing C-language functions and function calls to functions which return pointers? For example, if I have a function my_function which return two integers through ...
137
votes
6answers
23k views

Is every language written in C?

Sometimes while programming in different languages (C/C++, C#), this thought comes to my mind: Is each and every language written in the C programming language? Is the C language the mother/father ...
0
votes
0answers
4 views

Help with enum in C [migrated]

I am trying to understand some C code in a legacy database. There are constructions there of the form: enum {a=0,b,c,d}; What does this achieve ? In the manuals, I only see constructions of the ...
2
votes
2answers
84 views

Should I use multiple state machines for a layered protocol?

When implementing a layered communications protocol are layers commonly implemented as state machines? I have an implementation of PMBus I am currently working on for an embedded device. I have a ...
-2
votes
0answers
20 views

Strange behaviour of visual studio 2008 with escape sequence [migrated]

Regarding C programming language, the descriptions of escape sequence does not resolve the output of following line in visual studio 2008. char * str = "??/abc"; printf( "%s", str ); it prints only ...
1
vote
0answers
70 views

How to use an enumeration type, when the values are not known at first?

We have a project, that consists of a cluster of C source code, a C library and a C++ library. The C++ library is dependent only upon the C library, or at least that is what I am trying to achieve. ...
11
votes
2answers
616 views

Java has the JVM, what does C have?

I know that C has a compiler but what determines execution performance? For example in an if else block, what if the code just had all ifs instead of if elses, what determines that all the ifs will ...
-1
votes
3answers
126 views

is it possible to make a gui in c without an external library [closed]

I was wondering if it is possible to make a gui application in c without the use of an external library (like gtk+ or wxWidgets). And if it not possible without the use of an external library, how ...
0
votes
2answers
103 views

Trouble understanding simple recursion in c [duplicate]

My function: int num(int x) { if(x>0) num(x-1); else return 0; printf("%d",x); } This function takes a input x and prints the numbers from 1 upto x.I can't seem to ...
13
votes
5answers
72k views

Is initializing a char[] with a string literal bad practice?

I was reading a thread titled "strlen vs sizeof" on CodeGuru, and one of the replies states that "it's anyways [sic] bad practice to initialie [sic] a char array with a string literal." Is this true, ...
0
votes
6answers
1k views

Why languages that compile to C/C++ generate unreadable, cryptic code? [closed]

I'm willing to compile certain language to C or C++ for some speedups. My idea was, though, to generate readable code and use structures such std::vector and similar wherever I can, expecting CLANG to ...
-3
votes
2answers
145 views

Can a high level language be faster than native C? [closed]

Hand-crafted C is almost unbeatable. If an experienced C developer knows what he is doing, he will be able to write C code much faster than higher level code. But can a medium/big programme written in ...
26
votes
11answers
7k views

typedefs and #defines

We all have definitely used typedefs and #defines one time or the other. Today while working with them, I started pondering on a thing. Consider the below 2 situations to use int data type with ...
0
votes
5answers
514 views

Is a makefile really needed

I have been programming in c/c++ for a while now, and I have never once used a makefile. I know that it is supposed to be useful when you are dealing with a large project, but I have always been able ...
10
votes
6answers
14k views

What does it mean to do a “null check” in C or C++?

I have been learning C++ and I am having a hard time understanding null. In particular, the tutorials I have read mention doing a "null check", but I am not sure what that means or why it's necessary. ...
3
votes
2answers
667 views

How do you usually compile C/C++ source code ? (Large code bases) [closed]

It's been quite some times since I began learning C and C++ but I've been very limited only to the Windows platform and the Visual Studio environment. Recently, I wanted to look into some open source ...
-1
votes
1answer
78 views

Understanding the solution of exercise 1.16 of K&R as given in the “The C Answer book”

The exercise 1.16 in K&R's book asks, Revise the main routine of the longest-line program so it will correctly print the length of arbitrary long input lines, and as much as possible of ...
11
votes
2answers
4k views

Why does C use the asterisk for pointers?

I'm just now learning about C. I find it odd that the creators chose the asterisk (*) as the symbol for pointers rather than a symbol that actually looks like a pointer (->). Considering how ...