|
Thanks very much to all: it's works and it's what i need.
For Albert Holguin and Aescleal: i think with "friends" it's more simple; thanks likewise.
|
|
|
|
|
Friends will work but you should always be aware of the coupling that introduces into your design.
|
|
|
|
|
/*
William Strickland
Project 3
Is Leap Year Portion
*/
#include <stdio.h>
#include <stdlib.h>
#include "..\..\stdbool.h"
bool isLeapYear(int *year);
int main(int argc, char *argv[])
{
int year = atoi(argv[4]);
printf("Name: William Strickland \n");
printf("Is Leap Year \n");
if (isLeapYear(&year))
{
printf("%d is a leap year", year);
}
else
{
printf("%d is not a leap year", year);
}
return 0;
}
bool isLeapYear(int *year)
{
if (*year % 4 == 0 && *year % 100 != 0)
{
return 1;
}
else if (*year % 100 == 0 && *year % 400 == 0)
{
return 1;
}
else
{
return 0;
}
}
|
|
|
|
|
0. Please edit your question and wrap your code in the appropriate tags.
1. "Not running" isn't very descriptive. Are you failing to hit the enter key after typing the name of the program ina console window, are you only building the program but not running it from an IDE, or perhaps, you're running the program and it produces unexpected output..
2. The program runs just fine.
3. This is the output I get when running from the console. (I assume you understand what argv[4] refers to. Hint: it's not a 4 character long input. argv[0] would hold "001-deleteMePlease" "001-deleteMePlease.exe")
D:\code\001-deleteMePlease\bin\Release>001-deleteMePlease.exe 1 2 3 2000
Name: William Strickland
Is Leap Year
2000 is a leap year
"When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down 'happy'. They told me I didn't understand the assignment, and I told them they didn't understand life." - John Lennon
|
|
|
|
|
Hi there,
I have learned the principles of OOP and implementations in both java and C++ either on my own or in my school courses but we only grazed it. At this point, I feel very uncomfortable with OOP and I need a good resource that will provide me with a great deal of problems that require OOP to solve (or are best solved using object oriented approaches), and their respective answers with clean code and good practices. I have had very very little practice with OOP and want to practice as much as possible to get comfortable with it. I have been searching a lot but I can't seem to find a good resource.
Optimally, I would like it to begin with very trivial questions and progressively become more and more difficult.
Thank you.
|
|
|
|
|
|
|
4india wrote: I think you can refer this refer this site for knowledge buildup. I think not; the first example I looked at is wrong.
|
|
|
|
|
He's just spamming - why would he care if it works?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Correct, more votes still needed.
|
|
|
|
|
Hi,
I want to generate a dump file automatically whenever the application crashed/hanged. Is there any option to do it or how to do it programatically as the developer don't know when that application crashes at client location.
Thanks in advance for your help.
|
|
|
|
|
AFAIK Dump Files are managed by the OS - whichever it is - so you should look on the OS documentation. It is probable that you need to instruct the OS that you want a dump file and of which kind you desire (short, long, kernel...).
For example see if
http://msdn.microsoft.com/en-us/library/d5zhxt22.aspx[^]
is of any use for you.
HTH
|
|
|
|
|
Hi,
Thanks for your reply.
|
|
|
|
|
You can tell windows to create these dmp's for you (starting from Windows Server 2008 and Windows Vista SP1).
See MSDN for details: Collecting User-Mode Dumps[^]
|
|
|
|
|
Hi,
Thanks for the reply.
|
|
|
|
|
Hi all,
I have to get the infomation from USB by C program.
Could you give me the ideas or C code??
Thanks all
|
|
|
|
|
Not unless you're just trying to access a file that's on a flash drive.
|
|
|
|
|
|
hello guys,
i have to write a simple project ... it is a hangman code in C#
i have this...but when I run it... i keeps printing twice some sentences... if anybody can help me... and if the user type something different from l ..when it is asked...everything goes wrong...
#include <stdio.h>
#include <string.h>
#define NUM_TRIES_ALLOWED 10
main()
{
int num_letters = 0,
count = 0,
tries = 0,
num_vis_chars = 0,
correct_guesses = 0,
correct_flag = 0,
repeat_flag = 0,
choice;
char guess,guessword;
char word[255] = " ";
char incorrect_letters[255] = " ";
puts( "Enter a word for player to guess." );
gets( word );
printf("Ready to start!\n");
num_letters = strlen( word );
char visible_word[num_letters];
for( count = 0; count < num_letters; count++ )
visible_word[count] = '*';
visible_word[num_letters] = '\0';
if (guess == visible_word[count]){
while( tries < NUM_TRIES_ALLOWED )
{
printf( "The word is: %s\n\n", visible_word );
printf("Number of turns remaining: %d", NUM_TRIES_ALLOWED-tries);
printf("\nWould you like to guess the word [w] or guess a letter [l]:");
choice = getchar();
if (choice=='l'){
printf( "\nWhat letter have you chosen?:\t " );
scanf( " %c", &guess );}
for( count = 0; count < num_letters; count++ )
if( guess == visible_word[count] || guess == incorrect_letters[count] )
{
repeat_flag = 1;
correct_flag = 1;
break;
}
if( repeat_flag == 0 )
for( count = 0; count < num_letters; count++ )
{
if( guess == word[count] )
{
visible_word[count] = guess;
correct_guesses++;
printf("\n**************************************************************\n\n");
printf("Good choice!\n\n");
if( correct_guesses == num_letters )
{
puts( "\n\nCONGRATULATIONS! You guessed the word!" );
printf( "WORD: %s\n\n", visible_word );
exit( 0 );
}
correct_flag = 1;
}
}
if( correct_flag == 0 )
{
incorrect_letters[tries] = guess;
tries++;
printf("\n**************************************************************\n\n");
printf("Bad choice!\n\n");
}
repeat_flag = 0;
correct_flag = 0;
}
puts( "You did not guess the word." );
printf( "WORD: %s\n\n", visible_word );
}
if (choice='w'){
printf( "\nWhat word have you chosen?:\t " );
scanf( "%s", &guessword );
if(guessword==word){
printf("CONGRATULATIONS! You guessed the word!");}
else{ printf("nops");
}
}
return 0;
}
|
|
|
|
|
Try using your debugger to identify exactly where the problem(s) occur.
|
|
|
|
|
my debugger screen is grey, I tried to do this....but I couldnt
|
|
|
|
|
I cannot even get your code to compile so I have no idea how you are managing to run it.
|
|
|
|
|
My up-vote for trying.
THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?!
-- C++ FQA Lite
|
|
|
|
|
A quick desk check suggested a number of errors, but I wanted to be sure.
|
|
|
|
|
Member 11189395 wrote: i have to write a simple project ... it is a hangman code in C# If this is true, then you should be in the C# forum. Otherwise, what you have shown looks like C code.
Member 11189395 wrote: i have this...but when I run it... i keeps printing twice some sentences... Have you stepped through the code using the debugger? Are you using Visual Studio, or some other IDE?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|