TkTkorrovi 69 Junior Poster

Well and you, Ancient Dragon, should understand the same as well. You in addition to everything blocked your private messages for me, in spite that i didn't write you anything offensive, except for asking to leave me alone. I always thought you are intelligent person with university education, so you must be able to understand.

TkTkorrovi 69 Junior Poster

Narue, don't you still understand that a peson, whose tongue is cut, no not only by you, but not this is important here, cannot reply you, so it doesn't make any sense to talk to me any more.

TkTkorrovi 69 Junior Poster

I think you well understand that you can allow yourself anything now, you cut my tongue, and i may not even be able to reply. All the words are meaningless after that.

TkTkorrovi 69 Junior Poster

OK, what i can say here, i'm forcefully violated against, i let it to everyone to think, what interests this may serve. My posts are edited against my will, a possibility to protect myself is taken from me here, if you even can read these words.

These of you who are interested, let's create our own place, only about c and linux. Because this place has even not so many visitors, and it's impossible to achieve peace here.

TkTkorrovi 69 Junior Poster

Well, at least i don't listen to you any more.

TkTkorrovi 69 Junior Poster

> That's not how buffering in C works. You're confused about the connection between a command shell and a C program.

One should understand that it's not possible to implement standard input with line buffering without the canonical mode.

> That explanation is completely worthless to anyone except those of us who already know how it works. Perhaps instead of blowing a lot of hot air, you could give examples of how the bits are changed according to the truth tables of the bitwise operators.

Look, you even didn't say that my explanation is wrong, what it isn't, anyone who knows anything about logical operators can confirm that. This kind of thing can be said about any sentence said by anyone, because this is a subjective claim, deliberately left unsubstantiated, or in the other words simply a vituperation put into a decent looking form. And now i have a substantiated reason to be angry, so i'm justified to use all caps, sorry but some person here cause me to do that, i can obviously otherwise have no hope that he/she would understand, though there likely cannot be no such hope at all. NARUE, YOU OFFENDED ME BRUTALLY AND FOULLY <offensive material snipped>

And so, i was unfortunate enough to get offended, only because i posted here, trying to explain things and help newbies, with no bad intentions whatsoever towards anyone. WHAT MISTAKE DID I DO BY WRITING A POST TRYING TO HELP A PERSON, TO DESERVE …

Rashakil Fol commented: Aliens are not allowed to get offended. -1
TkTkorrovi 69 Junior Poster

Well it's getchar but getchar is not exactly equivalent to the getche in borland c... By default, the standard input in c is in the canonical mode, which means that all input is line buffered and the line would be received only after the linefeed. This means that no matter what function we use for input, we have to press enter after anything we write, for it to become available. At least it must be so by standard, because standard input must be line buffered, if any compiler implements it otherwise for some standard c functions, then this compiler does not conform to standard. So, we cannot use input in non-canonical mode, in standard c, which means also that one cannot use compiler flags like -std=c89, to force a strict standard c, one must compile in that case without these flags.

So we cannot switch off the canonical mode by standard c functions, but we can do it using standard posix functions. POSIX is a standard which somewhat can be considered as an extension of the standard c library, as standard c library is a subset of it, but posix enables to do everything which is necessary to communicate with the operating system. In posix, there is a header termios.h, which provides functions necessary to change the terminal attributes, and the canonical mode is one of these. Unfortunately windows doesn't implement posix (though one can buy from ms some posix extension to windows or such), in spite that it's …

TkTkorrovi 69 Junior Poster

I don't know, maybe it's c++, like there are every kind of weird << and >> in cout... But at least it's not c. Following the typedef identifier should be a declaration, which mostly starts with a type, not with map> something... With typedef you define type, you can use this to declare another type, or array of another type, or use it in whatever way how you can use simple types like char and int.

WolfPack commented: One of the most absurd half-assed answers I have ever seen. If you are not sure, please don't reply and confuse others. -1
TkTkorrovi 69 Junior Poster

There is xsane for windows http://www.xsane.org/xsane-win32.html free and open source, this can be used separately or together with gimp.

TkTkorrovi 69 Junior Poster

Apparently you must be speaking from ignorance of the capabilities of a modern linter.

I likely don't know, what you call the "modern linter", but does it really demand (void) before some function calls? When the function's return value was not used, this means that we didn't need it, no need for such warnings.

TkTkorrovi 69 Junior Poster

Since some compilers (and lint) will warn about discarded return values, an explicit cast to (void) is a way of saying "Yes, I've decided to ignore the return value from this call.

lint is outdated, compilers have now good enough error checking, so that we don't need lint. gcc at least doesn't give such warning even when all warnings are on, i don't know any compiler which gives such warning, though maybe there is some.

TkTkorrovi 69 Junior Poster

It's for some reasons better to compile and run the programs using command line, but if you want to use ide, then you may write something like this in the end:

printf ("== press enter ==\n");
getchar ();

Notice that you cannot use any other single character than newline for that, when you use only standard c, because in standard c the standard input is line buffered.

TkTkorrovi 69 Junior Poster

I don't know what this "opening a folder" exactly supposed to mean, but one thing which is usually always available, no matter what desktop you use, is xterm. This opens xterm in the directory /pathname/foldername and prints the directory contents:

system ("xterm -e 'cd /pathname/foldername && ls && bash'");

Then you can do everything with the files in that directory.

TkTkorrovi 69 Junior Poster

Yes OS supposed to free all the memory allocated by the program when the program exits. But nevertheless, it's a good habbit to free all allocated space when no longer needed, because the program may later be changed in a way that memory would be repeatedly allocated, and the amount of unused allocated memory would constantly increase when we forgot to free it. The failure to free the allocated space when no longer needed, is called memory leak. This may happen when we forget to free the memory, or when we are not able to do it, because we for some reason lost the pointer pointing to the allocated memory, as was the case above. Memory leak is harmful because it may cause the amount of memory allocated by the program to increase without control while the program runs. This may easily become serious when we allocate large amounts of memory or allocate frequently (in fact, some systems never allocate less than some 4 kb page at a time), everything may happen fast, and sometimes may well be possible that our program allocates all the available memory in the system, even if we have a gigabyte of memory.

TkTkorrovi 69 Junior Poster

I want to say only that, use some more modern compiler than turbo c, like gcc (mingw or cygwin in windows). Turbo c is an extinct compiler, somewhat hopelessly outdated, and you cannot find libraries for it etc. Otherwise, using conio is perfectly ok, there is conio for windows, and there is also conio for linux, so we may say it's a cross-platform library, and at that very easy to implement. There are really no better alternatives for windows, because windows console is so primitive that it cannot accept ansi terminal escape sequences. And it doesn't make sense to learn curses, as today it doesn't make sense any more to write user interfaces in text mode, but gui is a bit too complicated for the most simple programs.

TkTkorrovi 69 Junior Poster

I don't know, in general, c doesn't guarantee really much concerning the exact layout of the structure in memory. So, using memcpy for structures, is likely not so good idea... The only good way to copy structures in c, is member by member. Therefore certainly, if something can be implemented as a multidimensional array, then it should be done so, all the copying and writing would be easier then.

TkTkorrovi 69 Junior Poster

Watch the '\n' in the end of your string, this appears among your ten characters, if you entered less than ten characters, well, and the rest of your characters would be garbage in that case, if you didn't define them as global, or init ether to space or zero...

Ohh yes, make sure to do this

char full_code_p [FILENAME_MAX]; /*>=11*/
full_code_p [0] = '\0';
/* or */
strcpy (full_code_p, "");

anywhere *before* you write your characters with sprintf.

TkTkorrovi 69 Junior Poster

Well, it's OK, in case of

char d1_p, d2_p, d3_p, d4_p,
    d5_p, d6_p, d7_p, d8_p, d9_p, d10_p;
sprintf (full_code_p,
    "%s%c%c%c%c%c%c%c%c%c%c",
    full_code_p,
    d1_p, d2_p, d3_p, d4_p,
    d5_p, d6_p, d7_p, d8_p, 
    d9_p, d10_p);

But your d1_p etc were not characters but pointers to character, as they appeared in your sscanf without &...

One more thing... If you write characters into string with sprintf, you don't need to add '\0' in the end of string, because sprintf does it.

TkTkorrovi 69 Junior Poster

Ohh i would say you get me a bit confused, with a strange code... But anyway, you don't need no functions from string.h to add characters to a string, but if you really like to do it with a function, then the only reasonable option is

sprintf (buffer, "%s%c", buffer, char);

but this function is in stdio.h, not string.h

TkTkorrovi 69 Junior Poster

What are you doing? Why do you need to have all these objects as function parameters when you input them in that same function, and where are all these objects defined? If all these "characters" are indeed defined as character arrays with the length of at least two characters, and the second character in all of these is '\0', well and everything else is correct, then your program could even work, otherwise it of course crashes. And of course you also have to consider, what if your dear user didn't enter ten characters, but less, then there would be '\n' and '\0' in your string, followed by some garbage characters, which you likely don't need in your string. But there is no need to add characters with strcpy, you can simply assign a character to a member of the character array, like buffer = c, where c is char c. But then of course you must always remember that the last character in a string must be '\0', which is the only way how it is possible to find the end of the string. What is good though, is that you input with fgets, not directly with scanf.

TkTkorrovi 69 Junior Poster

I don't quite understand what do you want to do, but maybe using tab (\t) somewhere in the printf format string would solve your problem.

TkTkorrovi 69 Junior Poster

I included stdlib.h, and my compiler doesn't give any warning, even with all warnings on. Without stdlib h it says "incompatible implicit declaration of built-in function 'malloc'" gcc 4.1.2, debian linux.

Salem commented: Yes +9
TkTkorrovi 69 Junior Poster

Try to comment out the suspicious code, like that containing GTGetUniqueFileName, and see whether it works then. To comment out you may use something like #if 0 and #endif Or, try to temporarily substitude the suspicious code with something not suspicious.

TkTkorrovi 69 Junior Poster

For just making out the logic, you can simply print the board every move, you can do this in standard C. For any more complicated output, you need some console or graphics. For console, the most standard method is to use terminal escape sequences, but these don't work in Windows, except maybe if you have some special console. Using curses library is not a good solution, as it makes sense to use terminal escape sequences only for the most simple output, for anything more complicated it's better to use some graphical user interface, such as GTK, which is good because it's cross-platform. For 2d games also sdl can be used, the biggest advantage of which is that it is fast, if you really need so much speed, or opengl, if you need 3d, but you can use these two mostly only for games.