Little bit late, but you should check if the files are realy opened before you use it.
…
FILE *fp = NULL, *outfile = NULL;
if ((fp = fopen("be.txt", "r")) == NULL) {
...
Type: Posts; User: WoodSTokk
Little bit late, but you should check if the files are realy opened before you use it.
…
FILE *fp = NULL, *outfile = NULL;
if ((fp = fopen("be.txt", "r")) == NULL) {
...
Please don't use fflush(stdin) !!!
I know that Microsoft has extend the function that is also usable for stdin, but this is only valid an OSes from Microsoft!
We discuss in this forum the language...
Undefined Behavior! You return a pointer to 'text', but 'text' is a local variable inside the function 'eingabe'.
At the time the function returns, the variable (and its space in memory) become...
And your comparisons are in real assignments.
'=' != '=='
Line 14 has also a error
printf("Number of vowels: %d\n", sentence);
I think it should be
printf("Number of vowels: %d\n", vowels);
strcpy(tmp, string1 + position);
Simply Pointer Arithmetic.
string1 is a array of characters.
If you use the name of a array without index, it returns the address to the first member of...
Definitions of struct and typedef should go in global scope.
You miss the name of your typedef.
// declare a struct and typedef in two steps
struct account_s
{
int profile_number;
...
Ops, sorry, should be
char ConvertedToString[] = "This is a test string!\n";
I asume that AllocatedString is declared as char pointer like:
char *AllocatedString = NULL;
Now, whats the size of AllocatedString?
Secondly, don't cast the returned value of malloc.
The...
Same problem here. int_8 has the same size as char. EOF will not fit in there.
Here is a solution with int (and a little bit shorter):
void PressEnter(void)
{
int EnterBuffer;
...
As GReaper says, it's implementation-defined.
Anyway, EOF is defined as a int and is larger then a char.
If you assign EOF to a char, it will be stipped down to 8 bit.
Now, it represent the char...
Additional what whiteflags says.
if(CharacterInput[ProgramCounter] == '\n' || CharacterInput[ProgramCounter] == EOF)
break;
CharacterInput is a array of chars. EOF is an integer and can...
I never have programmed for Arduino, but this should work.
It shows also how a function return a value, so you don't need global variables.
uint32_t readADS1231(void)
{
uint32_t...
No problem, You are welcome.
I have started to think that my wording was incorrect, because I am not a nativ english speaker. ;)
Where have I told you that this is wrong???
I dont know where you find a contradiction. Both examples uses 'fgetc' and both assign the returned value to a int-variable.
BTW, you should...
Hmmm, so if you calculate the day of 10th of February (month == 2), you add one day if the year is a leap year.
So 10th of Feb is normaly day 41, but in a leap year it is day 42?
And 1st of March?...
The difference is:
'fgetc' return 'EOF' if there was no character left to read.
'feof' return a value that will be interpreted as 'true' if the eof-flag of the stream is set.
But the eof-flag will...
'c' is a variable and return nothing. It can only represent a value according to the type.
The function 'fgetc' return a value of type int. This means, the variable you assign the returned value...
'c' is a variable and return nothing. It can only represent a value according to the type.
The function 'fgetc' return a value of type int. This means, the variable you assign the returned value...
You should check the input from user.
…
int days_per_month[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
…
// after the user entered the input in main
// check year
Your comparition will allways be true, because 'c' can't represent EOF.
Look at fgetc - C++ Reference
The function 'fgetc' returns a 'int'.
This means you should declare 'c' as 'int'.
Your compiler should warn you about the print_list() function.
The printf() inside the function has to less arguments.
I have also edited the arguments itself to use the arrow-operator.
void...
You pulled that out of your ass. Windows works that way, but linux doesn't.
[/QUOTE]
The quoted line from Horror is from the fflush man-page of linux.
But this doesn't mean stdin, because stdin...
The system doesn't matter. C is OS independent! Every beginner should learn programming with the C-Standard in mind.
You can also learn features that some OSes add on top of the C-Standard, but then...
NO! Never use fflush() on streams that was open for input or input/output where the last operation was input!
Only use fflush() on streams that was open for output or input/output where the last...