Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c46e46d

Browse files
authored
Fix Love-Calculator
It wasn't working with spaces and uppercase.
1 parent b4ea320 commit c46e46d

File tree

1 file changed

+7
-7
lines changed
  • Windows_System_examples/Love-Calculator

1 file changed

+7
-7
lines changed

‎Windows_System_examples/Love-Calculator/main.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#include <stdlib.h>
33

44

5-
void enter_string(char* message, char* s, size_t s_size) {
5+
void enter_string(char* message, char* s, size_t s_size)
6+
{
67
printf("%s", message);
78
fgets(s, s_size, stdin);
89
}
@@ -23,13 +24,12 @@ int get_score(char* s)
2324
char c;
2425
for(char* p = s; p != end; ++p)
2526
{
26-
c = *p ^ 0x20;
27+
c = *p;
28+
if(c == ' ') continue;
2729

28-
if(c == ' ')
29-
{
30-
continue;
31-
}
32-
else if(c >= 'A' && c <= 'Z')
30+
c &= ~0x20;
31+
32+
if(c >= 'A' && c <= 'Z')
3333
{
3434
score += c - '@';
3535
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /