• What is/was the certain use of that \a escape sequence?

According to the same section of the standard you were reading,

Alphabetic escape sequences representing nongraphic characters in the execution character set are intended to produce actions on display devices as follows

The particular action that a \a sequence is intended to produce is what you quoted. This is in fact used rarely, if ever, in modern code, and typical C implementations just map that sequence to a single ASCII character that has the same significance, relying on the terminal driver to handle the actual alert. You're more likely to see the effect if you accidentally output a binary file to a terminal than just about any other way.

  • Is it a remain from the earlier days of C, that is obsolete now?

I am not aware of it being used for the purpose described in any code I have ever seen. In that sense, yes, it is obsolete, but from the perspective of the standard, that provision is not obsolete.

  • And in which situation it would be or were (if it is obsolete today) appreciated to use that? Can you provide an example?

You would include that sequence in a string that is printed to stdout. When the string is printed, you (maybe) get a bell sound and / or the screen flashes and / or something similar.

printf("Ring the bell...\a\n");
Answer from John Bollinger on Stack Overflow
🌐
Quora
quora.com › Where-do-we-practically-use-a-in-c-programming
Where do we practically use '\a' in c programming? - Quora
Quora is a place to gain and share knowledge. It's a platform to ask questions and connect with people who contribute unique insights and quality answers.
🌐
W3Schools
w3schools.com › c › c_operators.php
C Operators
Operators Arithmetic Assignment Comparison Logical Precedence Code Challenge C Booleans · Booleans Real-Life Examples Code Challenge C If...Else · if else else if Short Hand If Nested If Logical Operators Real-Life Examples Code Challenge C Switch ... C Functions C Function Parameters C Scope C Function Declaration C Functions Challenge C Math Functions C Inline Functions C Recursion C Function Pointers
🌐
Programiz
programiz.com › c-programming › c-operators
Operators in C
April 27, 2022 - Here, the operators ++ and -- are used as prefixes. These two operators can also be used as postfixes like a++ and a--. Visit this page to learn more about how increment and decrement operators work when used as postfix.
🌐
GeeksforGeeks
geeksforgeeks.org › c language › operators-in-c
Operators in C - GeeksforGeeks
Operators in C are special symbols used to perform operations on variables, constants, and expressions.
Published   1 month ago
🌐
Wikipedia
en.wikipedia.org › wiki › Operators_in_C_and_C++
Operators in C and C++ - Wikipedia
1 week ago - When not overloaded, for the operators &&, ||, and , (the comma operator), there is a sequence point after the evaluation of the first operand. Most of the operators available in C and C++ are also available in other C-family languages such as C#, D, Java, Perl, and PHP with the same precedence, ...
Find elsewhere
🌐
Reddit
reddit.com › r/dothack › does anybody know why the tone is called "a in c major"?
r/DotHack on Reddit: Does anybody know why The Tone is called "A in C major"?
May 30, 2024 -

It's just one note. Without any other pitches for context, it could just as easily be A in D, E, F, G, A or B♭ major, or their relative minor scales.

Keyboard images taken from piano-keyboard-guide.com

I'll admit there's plenty of .hack media that I haven't seen/played/read, but I've only ever heard it as a single note. Is there something that explains how they decided it's in C major?

EDIT: Answer seemingly found. I looked further into the original Japanese after u/rose-ramos suggested it could be a translation issue. It looks like an alternate translation would be "La in C major." That makes a lot more sense.

For those not in the know, there are multiple ways to refer to notes. Using C major as an example, you've got the letters, C D E F G A B, and you've got solfège, Do Re Mi Fa Sol La Ti. You might be familiar with solfège if you've heard that song from The Sound of Music ("Do, a deer, a female deer. Re, a drop of golden sun." Etc.)

The interesting thing about solfège is that it can change. You've got fixed Do solfège, where Do is C, Re is D, etc., and you've got movable Do, where Do refers to the root note of the scale. In C major, that means Do Re Mi is C D E, but in D major, that means Do Re Mi is D E F#.

So there it is. With the movable Do system, La in C major is indeed A, but just calling it A gets rid of the context that would make it necessary to specify that it's in C major.

🌐
Fandom
dothack.fandom.com › wiki › A_in_C_major
A in C major | .hack//Wiki | Fandom
— Mai Minase — A in C major (ラ音) is a musical note that is heard when players are temporarily drawn into The World or The World R:2, often coinciding with the appearance of an AI or other abnormality unrelated to normal gameplay.
Top answer
1 of 11
211

What you are comparing are the two memory addresses for the different strings, which are stored in different locations. Doing so essentially looks like this:

if(0x00403064 == 0x002D316A) // Two memory locations
{
    printf("Yes, equal");
}

Use the following code to compare two string values:

#include <string.h>

...

if(strcmp("a", "a") == 0)
{
    // Equal
}

Additionally, "a" == "a" may indeed return true, depending on your compiler, which may combine equal strings at compile time into one to save space.

When you're comparing two character values (which are not pointers), it is a numeric comparison. For example:

'a' == 'a' // always true
2 of 11
52

I'm a bit late to the party, but I'm going to answer anyway; technically the same bits, but from a bit different perspective (C parlance below):

In C, the expression "a" denotes a string literal, which is a static unnamed array of const char, with a length of two - the array consists of characters 'a' and '\0' - the terminating null character signals the end of the string.

However, in C, the same way you cannot pass arrays to functions by value - or assign values to them (after initialization) - there is no overloaded operator == for arrays, so it's not possible to compare them directly. Consider

int a1[] = {1, 2, 3};
int a2[] = {3, 4, 5};
a1 == a2 // is this meaningful? Yes and no; it *does* compare the arrays for
         // "identity", but not for their values. In this case the result
         // is always false, because the arrays (a1 and a2) are distinct objects

If the == is not comparing arrays, what does it actually do, then? In C, in almost all contexts - including this one - arrays decay into pointers (that point to the first element of the array) - and comparing pointers for equality does what you'd expect. So effectively, when doing this

"a" == "a"

you are actually comparing the addresses of first characters in two unnamed arrays. According to the C standard, the comparison may yield either true or false (i.e. 1 or 0) - "a"s may actually denote the same array or two completely unrelated arrays. In technical terms, the resulting value is unspecified, meaning that the comparison is allowed (i.e. it's not undefined behavior or a syntax error), but either value is valid and the implementation (your compiler) is not required to document what will actually happen.

As others have pointed out, to compare "c strings" (i.e. strings terminated with a null character) you use the convenience function strcmp found in standard header file string.h. The function has a return value of 0 for equal strings; it's considered good practice to explicitly compare the return value to 0 instead of using the operator `!´, i.e.

strcmp(str1, str2) == 0 // instead of !strcmp(str1, str2)
🌐
TutorialsPoint
tutorialspoint.com › cprogramming › c_operators.htm
C - Operators
The most common arithmetic operators are addition (+), subtraction (-), multiplication (*), and division (/). In addition, the modulo (%) is an important arithmetic operator that computes the remainder of a division operation. Arithmetic operators are used in forming an arithmetic expression.
🌐
Quora
quora.com › What-is-meant-by-*-int-*a-in-C
What is meant by * (int *a) in C? - Quora
Answer (1 of 5): This line will give a compiler error in any program. But it actually mean this “VALUE AT THE POINTER a” Always remember this notation “*” means “value at” [code]* --> Value at [/code]So int *a is simple pointer declaration. And [code ]*(int *a)[/code] → [code ...
🌐
Sololearn
sololearn.com › en › Discuss › 582217 › explain-the-meaning-of-a-and-a-in-c
Explain the meaning of a++ and ++a ? In c++
Maximum Storage Duration: SessionType: HTTP Cookie · ARRAffinitySameSiteUsed to distribute traffic to the website on several servers in order to optimise response times.
🌐
Quora
quora.com › What-is-the-difference-between-using-a-and-a-in-C-programming
What is the difference between using 'a++' and '++a' in C programming? - Quora
Answer (1 of 3): There are several types of differences, i.e., the differences come in several categories, e.g., the intentionality of the writer: some writers intend to use the value of the variable ‘a’ before or after its actual increment takes place. That is a difference compared with the ...
🌐
Programiz
programiz.com › c-programming › examples › alphabet
C Program to Check Whether a Character is an Alphabet or not
In the program, 'a' is used instead of 97 and 'z' is used instead of 122. Similarly, 'A' is used instead of 65 and 'Z' is used instead of 90. Note: It is recommended we use the isalpha() function to check whether a character is an alphabet or not.
Top answer
1 of 6
4

It counts the number of occurrences of each letter.


'A' is just a number. On an ASCII-based machine, 'A' is just another way of writing 65.

In ASCII, the 26 latin uppercase letters are found consecutively, so,

  • 'A'-'A' = 0
  • 'B'-'A' = 1
  • 'C'-'A' = 2
  • ...
  • 'Z'-'A' = 25

(Note that this code doesn't work on EBCDIC machines because the letters aren't contiguous in that encoding.)

So letter[c - 'A'] produces a unique element of letter for each letter.

Finally, ++x increments the value of x, so ++letter[c - 'A'] increments the element of letter that corresponds to the letter in c.

For example, if we read in ABRACADABRA, we'll end up with

int letter[26] = {
    /* A  B  C  D  E  F  G  H  I  J  K  L  M */
       5, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    /* N  O  P  Q  R  S  T  U  V  W  X  Y  Z */
       0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0
};
2 of 6
2

regarding:

if ('A' <= c && c <= 'Z') 
     ++letter[c - 'A'];

would be much better written as:

if( isupper( c ) )
{
    letter[ c-'A' ]++;
}

where isupper() is exposed via the header file ctype.h

regarding:

for (i = 0; i < 26; ++i) 
   letter[i] = 0;

can be eliminated IF this:

int c, i, letter[26];

had been written as:

int c, i, letter[26] = {0};

Now for your question:

letter[] is an array for all the capital (ASCII) alphabet where letter[0] is a counter for the letter A.... letter[25] is a counter for the letter Z.

This calculation:

[ c-'A' ]

is taking the ordinal value in the variable c and subtracting the ordinal value of the capital letter A. I.E. if c contains A then the result is 0 (which matches the index for the letter A in the array letter[]

The ++ says to increment the value in the array letter[]

The overall result is the entry in the array letter[] for the current letter in c will be incremented, thereby keeping a count of the number of occurrences of each capital letter encountered in the input

🌐
cppreference.com
en.cppreference.com › c › language › operator_precedence
C Operator Precedence - cppreference.com
The standard itself doesn't specify precedence levels. They are derived from the grammar. In C++, the conditional operator has the same precedence as assignment operators, and prefix ++ and -- and assignment operators don't have the restrictions about their operands.
🌐
Programiz
programiz.com › article › increment-decrement-operator-difference-prefix-postfix
Increment ++ and Decrement -- Operator as Prefix and Postfix
In this article, you will learn about the increment operator ++ and the decrement operator -- in detail with the help of examples in Java, C, C++ and JavaScript.
🌐
Quora
quora.com › What-is-meant-by-a-and-a-in-the-C-language
What is meant by a++ and ++a in the C language? - Quora
Answer (1 of 8): a++ means post increment and ++a means pre increment. Now in post increment, the value is used first and then a is incremented by 1. In pre increment value is incremented by 1 then used. Here is an example Say a =5 Now if we say b=a++, then b is assigned the value 5 and then a...
🌐
W3Schools
w3schools.com › c › c_data_types_characters.php
C Character Data Types
For now, just know that we use strings for storing multiple characters/text, and the char type for single characters. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com