Solved

Linux: shared memory odd problem

Posted on 2009-05-08
6
744 Views
Last Modified: 2012-06-27
Hello
I hate ask long and odd questions but this problem make me really insane!!!!!!! please help me. I apologize you.

I coded a game in Linux and it works. (fireballs.cpp)
I decided to code it using shared memory and fork. (fork.cpp)
it works but Player class's Move function that should move player's shield, doesn't clear previously printed characters.

I hope help me

want to mention compilation command:
g++ fork.cpp -o fork.o -lpthread -lncurses -O2 (also for fireballs.cpp)

I apologize you again for my long and odd question. please help me
thank you very much
yours sincerely
fireballs.txt
fork.txt
0
Comment
Question by:CSecurity
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
eager earned 400 total points
ID: 24343939
Run your program under a debugger (gdb, for example) and step through the code which you expect to clear the characters.

It's a bit tricky to debug a program which forks, because the debugger will only follow the parent, not the child process.  One way around this is to print the PID for the child and have it sleep for a while, which will allow you enough time to attach to the child process.  
0
 
LVL 53

Assisted Solution

by:Infinity08
Infinity08 earned 100 total points
ID: 24352225
Maybe you should simply clear the screen before drawing in the main loop ?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24480925
>> it's clear why!

No it's not :)

Do you still have a problem with this ? Did you try our suggestions ?
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 17

Author Closing Comment

by:CSecurity
ID: 31579655
although you did not help me but giving you some point will happy me!
thank you very much for your comment
infinity, my friend, sorry!
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24481055
>> although you did not help me

If you want, we can help you further. There's no need to close the question if you don't have a solution. If you explain to us what the problem currently is, we'll be happy to assist you with that :)
0
 
LVL 17

Author Comment

by:CSecurity
ID: 24481348
my friend
my problem was so odd and hard to tell it to someone else, unfortunately!
so, now I don't want to fix the problem because I don't need the code anymore!
so, I apologize you anymore
regards
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Fine Tune your automatic Updates for Ubuntu / Debian
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question