Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Linux: shared memory odd problem

Posted on 2009-05-08
6
745 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

840 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