Code: Select all
#include "stdio.h"
int main() {
static char buffer[1000000];
int cnt = 0;
while (fgets(buffer, 1000000, stdin) != NULL)
+cnt;
if (cnt % 2 != 0) {
char* c = NULL;
*c = '\0';
}
return 0;
}
Thanks.
Moderator: Board moderators
Code: Select all
#include "stdio.h"
int main() {
static char buffer[1000000];
int cnt = 0;
while (fgets(buffer, 1000000, stdin) != NULL)
+cnt;
if (cnt % 2 != 0) {
char* c = NULL;
*c = '\0';
}
return 0;
}
Code: Select all
char* c = NULL;
*c = '\0';
Code: Select all
char* c = NULL;
*c = '\0';
Code: Select all
#include "stdio.h"
int main() {
static char buffer[1000000];
int cnt = 0;
while (fgets(buffer, 1000000, stdin) != NULL)
+cnt;
if (cnt % 2 != 0) {
char* c = NULL;
*c = '\0';
}
return 0;
}
Code: Select all
#include "stdio.h"
static char buffer[1000000];
int main() {
int cnt = 0;
while (fgets(buffer, 1000000, stdin) != NULL)
+cnt;
if (cnt % 2 != 0) {
char* c = NULL;
*c = '\0';
}
return 0;
}
It's not a variable. it's an lvalue. It's something at address 0, which in almost all OSes you usually can neither read nor write, so that code causes a runtime error.hi!man! wrote:No, that is not the reason.Code: Select all
char* c = NULL; *c = '\0';
*c is not pointer, it is a variable.