Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
char b;
while((b=getchar()) != '.' );
{
printf("%c",b);
}
If I had the following input in stdin abcd.
it should print a then b then c then d then detect the . and terminate although its simply printing a . instead of abcd
Remove the semicolon at the end of while condition
The semicolon at the end of the while loop makes it execute only once . It does not loop at all . Your program is simple a linear program with no looping .
Otherwise your program logic is fine .
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
#include<stdio.h>
#include<conio.h>
void main()
{
printf("%d","");//printing output
getch();
}
The output is 173 .I am not getting why the output is 173.
First, you're trying to print a string as decimal integer, which means the decimal you try to print is going to be the pointer to the string (actually a pointer to the array of characters) and not the string itself. To use an individual character use single-quotes, not double-quotes.
To accomplish what you're actually trying to do, do this:
printf("%d", ' ');
Note there is an actual space between the two single-quotes.
The result will be 32, which is the decimal value for the ASCII Space character.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
error: expected expression before ';' token
graph[ ptr->count ].count- ;
^
I am getting the error shown when I compile my code in Geany. Can anyone please help what to do?
Assuming you’re trying to decrement...count by 1...you need one more minus sign, like this
int i = 10;
i--;
to be a valid expression in C/C++.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm learning C and trying to understand the printf function better.
When I print:
printf("%d", 6 << 1);
it returns 120x0 instead of the expected 12. Why is that? I'm using gcc compiler.
Change this
printf("%d", 6 << 1);
to
printf("%d\n", 6 << 1);
and try to always add a newline character to distinguish the printed text from other output, unless you need to print things next to each other.
You should now see
12
0x00
most likely you're code is working properly printing 12 and later you print 0x0 somewhere.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 9 years ago.
Improve this question
For example:
void thisIsAnExample(Hello* bye, char* name, int num, in* arr, int* sum){
GoodBye x;;
x.funName = name;
.
.
.
It doesn't mean anything. It's just an extra semicolon. You can delete it (leaving a single semicolon) without any effect on your program.
It has the meaning of an a statement followed by an empty statement.
In C each statememnt ends with ;. So a statement with a ; followed by one, is a statement followed by an empty statement.
A "double semicolon" does not have any special meaning in c. The second semicolon simply terminates an empty statement. So you can simply remove it.
Most likely a typo. Adds a null statement to your program.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
can someone please tell me how to check in c that a particular letter was pressed ?
I want to check if the letter 'r' was pressed. here is a small part of my code, where I need to check if it was pressed.
ch = getch();
if(ch==r)
i=1;
else
i=2;
the program considers the 'r' in my 'if' as a variable, but I want it to be considered as a letter so I would be able to check if it was pressed. can someone please tell me how to do that ?
Put the 'r' in single quotes:
ch = getch();
if(ch=='r')
i=1;
else
i=2;