(Forth || Factor) && (Scheme || Lisp). :) If the choice between C and Python only, then certainly C. Its main advantage lies in the fact that it is low-level. When you need something high-level, you...
Type: Posts; User: zub
(Forth || Factor) && (Scheme || Lisp). :) If the choice between C and Python only, then certainly C. Its main advantage lies in the fact that it is low-level. When you need something high-level, you...
while( fscanf(fp, "%s", str) == 1 ) {
if( strcmpi(string, str) == 0 ) {
found = 1;
break;
}
}
Why "found" uninitialized? Why it is compared in such strange way: <= 1?
You can use more readable variation of same loop:
while( 1 ) {
c = getchar();
if( c == EOF || c == '\n' ) { break; }
text[n] = c;
++n;
}
Hint: Changing the order of factors does not change their product. So, you can calculate 1 x 2 x 3 x ...
P.S. I recommend Sublime Text 2 (commercial editor, but it's trial period is eternal) and...
I do not understand the meaning of such learning. C language is not easy. Yes, it is a small language, but it has his own idiom, its programming techniques developed over many years. In a few months...
Sieve of Eratosthenes - Wikipedia, the free encyclopedia
1. Global variables are bad thing. Variable "o" must be declared inside main() function;
2. Names "o", "O", "l" (little L), "I" (big i) are very bad. I hope, reason is obvious.
3. Mathematical...
A few clarifications: I use Windows and Tiny C Compiler. Most comfortable for me the following options:
1. Library is a source code that can easily be included (a vivid example is SGLIB, it...
In the book "97 things every programmer should know" said that the invention of bicycles can be useful. So we know how it works, and gaining experience. That's fine, but I've reached the stage where...
Split program to little parts and test each of them independently - C Testing for Embedded Applications with greatest
For example, this is simple function, that fills array with numbers, extracted...
Just add check for door state too: opened or closed. It must be first check, because it does not make sense to check whether or not to close the closed door, and whether it is necessary to open the...
void remove_spaces(char* dst, const char* src)
{
int previous_symbol_was_space = 0;
int c;
while( c = (unsigned char) *src++ ) {
if( previous_symbol_was_space && c == ' ' ) {...
Run program in command line.
You needn't set '\0' multiple times. You needn't "return;". By the way, what happend, if string have no spaces at all? I advice you to use unit testing framework, for example greatest. Correct...
Yes, I misunderstood the task. I thought topicstarter come from a country where the decimal point is written with a comma (as in Russia).
Tip: Create a dummy element in each list. It point to the first element. This greatly simplifies inserting and deleting. For example, to insert an element at the beginning of the list, we just insert...
Rewrite your code in testable way. For example:
float getHeight(const float ft, const float in)
{
return 0.3048 * ft + 0.0254 * in;
}
#include "greatest.h"
char* third_column(char* str)
{
char* ret = NULL;
int space = 0;
while( *str ) {
space += *str == ' ';
switch( space ) {
case 2:
char* third_column(char* str)
{
char* ret = NULL;
int space = 0;
while( *str ) {
space += *str == ' ';
switch( space ) {
case 2:
if(...
It is very convenient. The fact that I make mistakes in this approach is due to my perfectionism (I scatter consts everywhere, necessary and not necessary). This does not mean that this technique...
I advise you to look at the source code of the unit-testing framework CuTest. About half of it takes a framework for working with strings of arbitrary length (CuString). It is a very convenient...
Your program is just one big plate of spaghetti. Split program to little, obvious pieces. For example:
typedef struct node node;
node* new_node(node* const previous, const int new_data)
{
...
Thank you for being enlightened, you are certainly right about my assumptions. I do not know much yet in such nuances.
I think this style have rights to exist in some kinds of programs....
/* My variation of Bernstein algorithm:
1. Perfect hashing for a string consist of no more than 6 symbols of the same type.
For example, alphabetic only or numeric only, but not alphanumeric....