Commit e1fa4486 authored by Hermann Krumrey's avatar Hermann Krumrey

Imported project into git repository

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<FileVersion major="1" minor="6" />
<Option title="Rock Paper Scissors" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Target title="Debug">
<Option output="bin/Debug/Rock Paper Scissors" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Add option="-g" />
<Target title="Release">
<Option output="bin/Release/Rock Paper Scissors" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Add option="-O2" />
<Add option="-s" />
<Add option="-Wall" />
<Unit filename="main.c">
<Option compilerVar="CC" />
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
# depslib dependency file v1.0
1395424367 source:c:\users\hermann\skydrive\c\rock paper scissors\main.c
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<ActiveTarget name="Debug" />
<File name="main.c" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor1 position="3374" topLine="0" />
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
int main(){
printf("Welcome to Rock Paper Scissors!\n\n"); //Introduction
int wloop1 = 0; //loop initiator 1
while(wloop1==0){ //while loop 1
int wloop2 = 0; //loop initiator 2
while(wloop2==0){ //while loop 2
printf("Do you choose ROCK, PAPER, or SCISSORS?\n"); //print user prompt
char user[256]; //define user variable
scanf("%s", user); //scan keyboard for user input
//printf("%s", user); //check userinput
int i = 0; //initiate toupper loop
while(user[i]){ //beginn toupper loop, end when at end of user-string
user[i] = toupper(user[i]); //toupper function
i++; //increment i
//printf("%s", user); //check userinput again
if(strncmp(user,"ROCK",4)==0||strncmp(user,"PAPER",5)==0||strncmp(user,"SCISSORS",4)==0){ //check if input is valid
printf("\nInput is %s\n", user); //Input analysis
wloop2 = 1; //loop 2 ender
else{ //condition to continue loop 2
printf("\nInput faulty\n"); //output error message and continue loop 2
srand(time(0)); //create random seed
int random = rand() % 99 + 1; //initiate random number between 1 and 100
char comp[255]; //Initiate PC choice variable
if(random<34){ //creation of random PC input
comp[255] = "ROCK";
comp[255] = "PAPER";
comp[255] = "SCISSORS";
printf("PC %s", comp); //check PC input
wloop1 = 0; //loop 1 ender
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment