Forum: C Aug 8th, 2009 |
| Replies: 3 Views: 387 If you have actually fork()ed (or spawn()ed) a child process, and you just want to check whether or not it has terminated, you want the waitpid() (http://linux.die.net/man/2/waitpid) function.
You... |
Forum: C Aug 6th, 2009 |
| Replies: 18 Views: 1,117 |
Forum: C Aug 6th, 2009 |
| Replies: 18 Views: 1,117 Well, Hiroshe, since your brain power is obviously so much greater than mine, the answer to your input question is simply: you've already figured it out.
Writing portable code has nothing to do... |
Forum: C Aug 4th, 2009 |
| Replies: 18 Views: 1,117 Standard C doesn't have any concept of console or graphics displays. Hence, what you are trying to do is technically impossible.
If you are using a graphics library then you should be able to get... |
Forum: C Aug 3rd, 2009 |
| Replies: 8 Views: 348 Wow, look a gift horse in the mouth...
If the library that ships with your OS isn't sufficient, or you want something portable (which <conio.h> isn't, BTW), try NCurses.
For Windows:... |
Forum: C Aug 3rd, 2009 |
| Replies: 18 Views: 1,117 Standard C doesn't have anything to do with it.
You need to modify the input stream's mode to "unbuffered". You probably want to turn off "echo" also.
Both of these things are OS-dependent... |
Forum: C Aug 3rd, 2009 |
| Replies: 6 Views: 539 Check out the <csetjmp> (http://www.cplusplus.com/reference/clibrary/csetjmp/) library.
Don't mess with the stack. Otherwise you invite death. |
Forum: C Aug 3rd, 2009 |
| Replies: 8 Views: 348 The GCC does not supply gotoxy() with <conio.h>.
Since it is a Windows program, why not use the SetConsoleCursorPosition() (http://www.google.com/search?btnI=1&q=msdn+SetConsoleCursorPosition)... |
Forum: C Apr 7th, 2009 |
| Replies: 3 Views: 1,177 The wait() (http://linux.die.net/man/2/wait) function monitors the state of a process, not its I/O streams. What you really want is the poll() (http://linux.die.net/man/2/poll) or select()... |
Forum: C Apr 2nd, 2009 |
| Replies: 5 Views: 427 Hey there, he has good reason for hating Solaris.
Make sure you are compiling with the GCC and not the Sun Studio CC. Also make sure you have the GNU make (gmake) installed and use it by default... |
Forum: C Apr 1st, 2009 |
| Replies: 2 Views: 568 I'm sure your instructor has given you much more information than you have given us.
Make sure you review how to open pipes:
man 7 pipe: overview (http://linux.die.net/man/7/pipe)
man 2 pipe:... |
Forum: C Mar 28th, 2009 |
| Replies: 1 Views: 775 It might help to consider what two things you are doing.
1) input an array
2) return its sum
The main program should work something like
main()
{
sum = 0; |
Forum: C Mar 28th, 2009 |
| Replies: 3 Views: 882 A structure is 'aligned' in memory to make it easy to access quickly. Search your compiler's documentation for "record alignment".
Hope this helps. |
Forum: C Mar 27th, 2009 |
| Replies: 3 Views: 882 Looks like it is being stupid about alignment? |
Forum: C Jan 31st, 2009 |
| Replies: 7 Views: 735 It is because you are reading input to random memory.
Line 24's num variable should be declared as:
char num[ 100 ];
(Where '100' is just the maximum number of character's I'd accept from the... |
Forum: C Jan 31st, 2009 |
| Replies: 2 Views: 224 Don't learn MFC if you can avoid it. ;)
If you aren't using Windows (or even if you are and want more choices) check out The GUI Toolkit, Framework Page (http://www.free-soft.org/guitool/).
... |
Forum: C Jan 31st, 2009 |
| Replies: 1 Views: 436 No.
Automatic variables are freed:
int foo()
{
int a = 42;
int* p = (int*)malloc( sizeof( int ) );
*p = a; |
Forum: C Nov 20th, 2008 |
| Replies: 3 Views: 483 Pattern recognition and image analysis is a complex subject. You are better-off hiring someone to do it.
Good luck! |
Forum: C Jul 19th, 2008 |
| Replies: 10 Views: 1,098 Salem is right. I almost said something about that myself but it has been a while since I've used select() and I forgot you aren't waiting on stdin (even though your comments say you are).
To wait... |
Forum: C Jul 18th, 2008 |
| Replies: 10 Views: 1,098 The FIFO will never have input until you write something to it. Since you don't write anything to it, select() will always say that there is no input waiting.
Remember, a FIFO must be open at both... |
Forum: C Jul 11th, 2008 |
| Replies: 4 Views: 561 I think you need to spend some time tracing through your algorithm. I'm not sure exactly what it is supposed to do, but I don't think it is doing what you want it to do...
(Given "HELLO", the list... |
Forum: C Jul 3rd, 2008 |
| Replies: 1 Views: 693 To get a filename without path or extension you need to do some string manipulations.
Here are three procs I use all the time (well, in C++... I haven't used C in a while):
#include <stdlib.h>... |
Forum: C Jul 2nd, 2008 |
| Replies: 8 Views: 690 Dev-C++ uses MinGW.
And AD only said he has seen the problem, not that he tried compiling OPs code.
The problem likely stems from the 16-bit executable trying to do something in a way that XP... |
Forum: C Jul 2nd, 2008 |
| Replies: 8 Views: 690 Here's a wild stab in the dark: you are using a really old compiler like Turbo C.
If I'm right, then you should visit one of the following and get yourself a compiler that makes 32-bit... |
Forum: C Jun 25th, 2008 |
| Replies: 4 Views: 1,612 If you are looking to port Win32 API code to Linux, take a look at Wine (http://www.winehq.org/). |
Forum: C Jun 25th, 2008 |
| Replies: 1 Views: 842 Here's my response to a similar question (on another forum) (http://www.cplusplus.com/forum/unices/2047/).
Hope this helps. |
Forum: C Jun 12th, 2008 |
| Replies: 3 Views: 544 Wrong forum. This is the C++ forum.
Binary I/O is straight-forward, but you need to be aware of certain caveats.
You never list the types of result and rest, but if they are different types... |
Forum: C Jun 5th, 2008 |
| Replies: 20 Views: 1,624 Sorry, haven't rebooted into Linux yet (I will before the night is through).
The way you are mixing standard I/O and curses is not very stable. In each case you must be certain to completely flush... |
Forum: C Jun 5th, 2008 |
| Replies: 20 Views: 1,624 Yep, it works perfectly for me.
Give me a little time to switch over to my Kubuntu partition and try it there.
[edit]
Before I get that far though, if your problem is just that you aren't... |
Forum: C Jun 4th, 2008 |
| Replies: 20 Views: 1,624 It works fine for me.
BTW, you should #include <curses.h>, not <ncurses.h>, unless you have special needs on a Solaris system.
I compiled using the GCC on Windows XP and PDCurses:
gcc a.cpp... |
Forum: C Jun 4th, 2008 |
| Replies: 20 Views: 1,624 Without a working (or failing, as it were) example I don't know what to say.
If you want to use the standard I/O again you need to do as explained:
endwin(); // leave curses mode
printf(... |
Forum: C Jun 4th, 2008 |
| Replies: 20 Views: 1,624 Frankly, you've confused me a little about how you are using curses. I don't know what is causing your error, but typically a curses program will work something like:
int main()
{
... |
Forum: C Jun 3rd, 2008 |
| Replies: 20 Views: 1,624 There are only a couple that I'd recommend.
First, straight from esr himself:
http://web.cs.mun.ca/~rod/ncurses/ncurses.html
And another very good one, replete with great examples:... |
Forum: C Jun 3rd, 2008 |
| Replies: 20 Views: 1,624 But for whole libraries (particularly conio.h) remember jephthah's words of wisdom.
If you think your program will do very much non-C-standard stuff with the console you should look at NCurses... |
Forum: C Jun 3rd, 2008 |
| Replies: 20 Views: 1,624 While the libraries are non-portable, don't worry too much about using _kbhit() or some other like function. If you do need to port someday, it is trivial to implement it in terms of the new... |
Forum: C Jun 1st, 2008 |
| Replies: 7 Views: 988 Heh heh heh...
My brain got so big because I studied the theory of computation... :-O
You can make your brain bigger by picking up a couple of texts on the same. ;)
Then questions like this... |
Forum: C May 31st, 2008 |
| Replies: 7 Views: 988 I think you are kind of close, but you need to be careful about a couple of things.
The first problem is that the variable lookahead is local to lexan(), so your compiler should be complaining... |
Forum: C May 31st, 2008 |
| Replies: 3 Views: 516 Numbers and strings are two different kinds of thing.
You'll need to convert between them. Use strtol() or strtoul() to turn your string into a number (long or unsigned long respectively).
Hope... |
Forum: C May 30th, 2008 |
| Replies: 13 Views: 25,515 |
Forum: C May 23rd, 2008 |
| Replies: 13 Views: 8,214 Get rid of that -c and try again. Linux only executes ELFs, not OBJs. |