C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 9th, 2013, 08:52 AM
Kuiva Kuiva is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 13 Kuiva User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 8 m 34 sec
Reputation Power: 0
I need help about FUNCTION

here is my screen output:


How am i gonna put them together? i mean side to side and not underneath of the other

here is my code:

Code:
#include <stdio.h>
#include <conio.h>

void paper()
{
	printf("      _____\n");
	printf("     /     \\\n");
	printf("    /   ___/_________\n");
	printf(" __/                 \\\n");
	printf("|           |________/____\n");
	printf("|                         \\\n");
	printf("|           |_____________/\n");
	printf("|                       \\\n");
	printf("|           |___________/\n");
	printf("|                   \\\n");
	printf("|_          |_______/\n");
	printf("  \\________/\n");
}

void rock()
{
	printf("      _____\n");
	printf("     /     \\_______\n");
	printf("    /       \\      |\n");
	printf(" __/         \\_____|\n");
	printf("|        \\   |     |\n");
	printf("|         \\__|_____|\n");
	printf("|           |      |\n");
	printf("|           |______|\n");
	printf("|           |      |\n");
	printf("|_          |______|\n");
	printf("  \\__________/\n");
}

void scissor()
{
	printf("      ___________________\n");
	printf("     /     \\             \\\n");
	printf("    /       \\    ________/\n");
	printf(" __/         \\  |___________\n");
	printf("|         \\   \\             \\\n");
	printf("|        __\\  |_|___________/\n");
	printf("|       /   \\_| \\\n");
	printf("|       \\_______/\n");
	printf("|        /     \\\n");
	printf("|_       \\_____/\n");
	printf("  \\__________/\n");
}

main()
{
	char p[2];
      
      printf("\t\t\t\tJACK EN POY");
      printf("\n\nBET OPTIONS");
      printf("\n\n[S or s] = SCISSOR\n[P or p] = PAPER\n[R or r] = ROCK");
      printf("\n\n\n\t\tPLAYER ONE's BET: ");
      scanf("%s", &p[0]);
      system("cls");
      printf("\t\t\t\tJACK EN POY");
      printf("\n\nBET OPTIONS");
      printf("\n\n[S or s] = SCISSOR\n[P or p] = PAPER\n[R or r] = ROCK");
      printf("\n\n\n\t\tPLAYER ONE's BET: ?");
      printf("\t\tPLAYER TWO's BET: ");
      scanf("%s", &p[1]);
      system("cls");
                    
                    
                    
      //PAPER-ROCK CONDITION              
      if((p[0]=='P' || p[0]=='p') && (p[1]=='R' || p[1]=='r'))
	  {
	  	printf("\t\t\t PLAYER ONE WINS! CONGRATULATIONS!\n");
		paper(); rock();
	  }
      
	  else if((p[0]=='R' || p[0]=='r') && (p[1]=='P' || p[1]=='p'))
	  {
	  	printf("\t\t\t PLAYER TWO WINS! CONGRATULATIONS!\n");
	  	rock(); scissor();
	  }
	  
                       
                       
      //SCISSOR-PAPER CONDITION                 
      else if((p[0]=='S' || p[0]=='s') && (p[1]=='P' || p[1]=='p'))
      {
      	printf("\t\t\t PLAYER ONE WINS!CONGRATULATIONS!\n");
      	scissor(); paper();
      }
      
	  else if((p[0]=='P' || p[0]=='p') && (p[1]=='S' || p[1]=='s'))
	  {
	  	printf("\t\t\t PLAYER TWO WINS!CONGRATULATIONS!\n");
	  	paper(); scissor();
	  }
      
                                             
      //ROCK-SCISSOR CONDITION                    
      else if((p[0]=='R' || p[0]=='r') && (p[1]=='S' || p[1]=='s'))
      {
      	printf("\t\t\t PLAYER ONE WINS! CONGRATULATIONS!\n");
      	rock(); scissor();
      }
       
      
	  else if((p[0]=='S' || p[0]=='s') && (p[1]=='R' || p[1]=='r'))
	  {
	  	printf("\t\t PLAYER TWO WINS! CONGRATULATIONS!\n");
	  	scissor(); rock();
	  }
      
                                              
      /*condtion 4 if input is invalid or the same user input*/
      else if((p[0]=='R' || p[0]=='r') && (p[1]=='R' || p[1]=='r'))
      {
      	printf("\t\t\t\t  IT's A DRAW\n");
      	rock(); rock();
      }
      
      else if((p[0]=='S' || p[0]=='s') && (p[1]=='S' || p[1]=='s'))
      {
      	printf("\t\t\t\t  IT's A DRAW\n");
      	scissor(); scissor();
      }
      
      else if((p[0]=='P' || p[0]=='p') && (p[1]=='P' || p[1]=='p'))
      {
      	printf("\t\t\t\t  IT's A DRAW\n");
      	paper(); paper();
      }
      
      else
      printf("\n\n\n\t\t\t      ERROR: INVALID INPUT");
      getch();
      return 0;
} 

Reply With Quote
  #2  
Old March 9th, 2013, 09:35 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,838 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 17 h 44 m 22 sec
Reputation Power: 1774
Do something like
Code:
char *paper[] = {
   "      _____",
   "     /     \\",
   "    /   ___/_________",
   " __/                 \\",
   "|           |________/____",
   "|                         \\",
   "|           |_____________/",
   "|                       \\",
   "|           |___________/",
   "|                   \\",
   "|_          |_______/",
   "  \\________/",
};
char *rock[] = {
   "      _____",
   "     /     \\_______",
   "    /       \\      |",
   " __/         \\_____|",
   "|        \\   |     |",
   "|         \\__|_____|",
   "|           |      |",
   "|           |______|",
   "|           |      |",
   "|_          |______|",
   "  \\__________/",
};


Then in a loop, you can do
printf("%40s%s\n", paper[i], rock[i] );
__________________
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper

Reply With Quote
  #3  
Old March 9th, 2013, 09:45 AM
Kuiva Kuiva is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 13 Kuiva User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 8 m 34 sec
Reputation Power: 0
Quote:
Originally Posted by salem
Do something like
Code:
char *paper[] = {
   "      _____",
   "     /     \\",
   "    /   ___/_________",
   " __/                 \\",
   "|           |________/____",
   "|                         \\",
   "|           |_____________/",
   "|                       \\",
   "|           |___________/",
   "|                   \\",
   "|_          |_______/",
   "  \\________/",
};
char *rock[] = {
   "      _____",
   "     /     \\_______",
   "    /       \\      |",
   " __/         \\_____|",
   "|        \\   |     |",
   "|         \\__|_____|",
   "|           |      |",
   "|           |______|",
   "|           |      |",
   "|_          |______|",
   "  \\__________/",
};


Then in a loop, you can do
printf("%40s%s\n", paper[i], rock[i] );



THANK YOU! =)

Reply With Quote
  #4  
Old March 9th, 2013, 11:18 AM
Kuiva Kuiva is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 13 Kuiva User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 8 m 34 sec
Reputation Power: 0
any other solution? i couldnt let it work >_>

Reply With Quote
  #5  
Old March 9th, 2013, 11:35 AM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,838 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 17 h 44 m 22 sec
Reputation Power: 1774
How about posting what you managed to achieve.

Then we can fix it.

> any other solution? i couldnt let it work >_>
Yes, the way I showed you, but implemented without the bugs you've put in.

Reply With Quote
  #6  
Old March 9th, 2013, 11:46 AM
Kuiva Kuiva is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 13 Kuiva User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 8 m 34 sec
Reputation Power: 0
i did it something like this

Code:
char paper(char x)
{
      char *paper[]= {
        printf("      _____\n");
	printf("     /     \\\n");
	printf("    /   ___/_________\n");
	printf(" __/                 \\\n");
	printf("|           |________/____\n");
	printf("|                         \\\n");
	printf("|           |_____________/\n");
	printf("|                       \\\n");
	printf("|           |___________/\n");
	printf("|                   \\\n");
	printf("|_          |_______/\n");
	printf("  \\________/\n");
    };
}


i feel that your solution is correct,perhaps i just dont know how to do it >_> kind of new in fucntions.

Reply With Quote
  #7  
Old March 9th, 2013, 03:45 PM
salem's Avatar
salem salem is offline
Contributed User
Click here for more information
 
Join Date: Jun 2005
Posts: 3,838 salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)salem User rank is General 12nd Grade (Above 100000 Reputation Level)  Folding Points: 153 Folding Title: Novice Folder
Time spent in forums: 2 Months 3 Weeks 2 Days 17 h 44 m 22 sec
Reputation Power: 1774
I said to put the strings in the arrays, not put the printf's in the arrays.

Then it's something like
Code:
void doPrint ( char *left[], char *right[] ) {
    printf("%40s%s\n", left[0], right[0] );  // except you make this a loop!
}


And you call it with
doPrint(rock,paper);

Reply With Quote
  #8  
Old March 9th, 2013, 04:15 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,128 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 18 h 42 m 39 sec
Reputation Power: 1949
Now that salem has explained the same thing to you for a second time, look at what he wrote, look at what you did, pay particular attention to how they differ.
Comments on this post
Kamikageyami agrees!

Reply With Quote
  #9  
Old March 9th, 2013, 11:14 PM
Kuiva Kuiva is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 13 Kuiva User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 8 m 34 sec
Reputation Power: 0
i have not learned bout POINTERS yet, and we are only allowed to use functions. i really dont have an idea, what you had explained Salem

but thank you BIG TIME! you bothered to answer my query

Reply With Quote
  #10  
Old March 14th, 2013, 11:57 AM
Kamikageyami Kamikageyami is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 16 Kamikageyami User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 52 m 53 sec
Reputation Power: 0
The problem isn't with pointers, you're trying to store the printf's inside your array.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > I need help about FUNCTION

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap