Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

works perfectly on Replit: My codes is too long so I include it in a online share text website: https://justpaste.it/cl4j5 The content in makefile: part2:

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

works perfectly on Replit:

image text in transcribed

image text in transcribed

My codes is too long so I include it in a online share text website: https://justpaste.it/cl4j5

image text in transcribed

The content in makefile:

part2: gcc -o part2 IERG2080_1155174712_part2.c

image text in transcribed

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

image text in transcribed image text in transcribedimage text in transcribed

image text in transcribed

image text in transcribed

Why my C program (not c++ ) works normally on online compiler but encounter bugs that the loop never ends on Linux system (using windows subsystem for Linux)? due to word limit, I change some word to photo My question looks very long, and you may not want to answer it. But in fact, I think it is straight forward and it looks long because I try to explain it more clearly. The only think you need to do it tell me how to solve the bug only appear in windows subsystem linux but not in the online compiler. It is a program for UNO. As it is part 2 only, so those action card like draw 4 is not included in my program. I have already finished my program but I don't know how to solve the bug only in the linux console in the windows but no in the online compiler. Here is the explanation so that you know what those file mean. Explanation for the files In part 1 to 3 , you can expect we use the following commands to run your program. For example, ./part1 init_cards_users.txt init_cards_stack.txt discard_pile.txt output.txt and are all input files, is both an input and output file, while is the output file. In , it specifies the number of users in the first line. Then, every two lines describe the initial hand of the user. First line is the id of the user. You can assume the id is a non-negative integer. Second line is the list of cards. For the description of the card format, see at the end of this part. In addition, the order of users to drop cards is the same as the input order in this file. In , it specifies the cards in the card stacks for draw upon (i) the user has no card to drop, or (ii) the user under the attack of a draw card. Each line describes one card. In =1 refers to the initial top card of the discard pile. Sample discard pile.txt before the start of qame Samnle discard nile.txt after the end of aame In , the first line displays the winner of the game. Then, the following lines describe the remaining cards of each user. For example, if it shows "1 R2", it means the user with id =1 has card R2 at the end. NULL means the user has no cards in hand. The order of users is the same as the file. The description of the cards: The following photos told you what the input and output. To debug my program, you need to create three input files e.g. init_cards_users.txt etc. and input the values showed below to test the program. In part 2, you are going to submit a source file, IERG2080_1155xxxxxx_part2.c. After compiling your code to an executable file, we will use the following command to test your program. \begin{tabular}{|l|} \hline./ executable init user init stack discard pile output file \\ For example, \\ ./ part2 init_cards_users.txt init_cards_stack.txt discard_pile.txt output.txt \\ \hline \end{tabular} You are advised to copy your result of part 1 to the start of part 2. So, make sure you don't have any problems in part 1, before you move forward to part 2. In part 2, you can assume (i) the number of players is at least 2, (ii) no action cards appear in part 2, and (iii) the stack will not be run out before we can determine the winner. You need to simulate the Uno gameplay for multiplayers with basic rules and detect the winning conditions (40%). In this part, your program needs to generate the exact output based on the input files. User will encounter either one of the two situations in his/her turn: (i) the user has some cards to drop, and drop the first possible card among all the cards in his/her list of cards, (ii) the user has no cards to drop, draws a card from the stack and inserts the card to the end of the list. Users cannot drop a card after drawing cards. The user who places the last card wins the game. Sample 1: Before the game: After the end of aame: But the loop never ends when I am using Linux, the program can only be terminated by command. Which act different to the compiler. Input: My codes with debug output (can use for debug): You can add // to all printf to remove my program for debug if you like \begin{tabular}{r|r|} 1 & part1: \\ 2 & gcc -o part1 IERG2080_1155174712_part1.c \\ 3 & \\ 4 & part2: \\ 5 & gcc - - part2 IERG2080_1155174712_part2.c \\ 6 & \\ 7 & part3: \\ 8 & gcc - o part3 IERG2080_1155174712_part3.c \\ 9 & \\ 10 & part4: \\ 11 & gcc -o part4 IERG2080_1155174712_part4.c -pthread \end{tabular} To conclude, to test my program, you should first create makefile with the above value, then enter my codes into IERG2080_1155174712_part2.c, then enter "gcc -o part2 IERG2080_1155174712_part2.c" to the linux console, then create the three different inputs.txt in the same folder: discard_pile.txt + discard_pile.txt 11G1 2 After entering " "/part2 init_cards_users.txt init_cards_stack.txt discard_pile.txt output.txt " the output should be: output.txt + output.txt WIN: 3 1 R5 G8 2G6 3 NULL However, my online compiler can generate the exact output but my linux console cannot, that's why I ask the question to help solve it. my output with the codes for debug (the second codes I mentioned above)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions