Debug problems with Scanf

Completed

Hallo im Trying to Debug in C-Lion but as soon as i hit a scanf the debugger does just show the message connected and i cant see the variables.

Before the Scanf it still shows variables like the Items of the voters array

Help would be nice

 

1
4 comments

Hello!

So far I didn't manage to reproduce the issue on my side. Please send the following materials to clion-support at jetbrains.com:

  1. Your project.
  2. A screenshot of `File | Settings | Build, Execution, Deployment | Toolchains` (please capture the screenshot after the compiler detection is completed).
  3. Please enable debugger logging as described here, reproduce the issue and send us the resulting idea.log file (`Help | Show Log in ...`). Do not forget to disable debug logging after that. Note that logs might contain private user's information (like file paths and names). 
0
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>

int main(void){
int j = 0, count = -1;
int temp =0;
int freq[100];
int voters[100];
int vote=0;
int visited = -1;
int i;
int age = 0;
int exit = 0;
char *parties[6] = {"Green Party","Conservative and Unionist Party","Scottish national Party","Labour Party","Liberal Democrats","Democratic Unionist Party"};
//parties[1] = "Conservative and Unionist Party";
//parties[2] = "Scottish national Party";
//parties[3] = "Labour Party";
//parties[4] = "Liberal Democrats";
//parties[5] = "Democratic Unionist Party";

while(exit == 0) {

printf("> Whats your Age? \n ");
setbuf(stdout, 0);
scanf("%d", &age);

if (age < 18) {
printf("\n You are underage\n");
for (i = 0; i <= age - 1; i++) {
printf("*");
}
printf("\n******************");

printf("\n DO you want to try again? \n 0: yes 1: no \n");
setbuf(stdout, 0);
scanf("%d", &exit);
if (exit > 1) {
printf("invalid input\n");
exit = 0;

}
} else {
printf("\n You are not underage\n");
for (i = 0; i <= age - 1; i++) {
printf("*");
}
printf("\n******************");
printf("\nChoose your vote:\n0:Green Party\n1:Conservative and Unionist Party\n2:Scottish national Party\n3:Labour Party\n4:Liberal Democrats\n5:Democratic Unionist Party\n");
setbuf(stdout, 0);
scanf("%d", &vote);
//printf("You voted for the %d.party",vote);

printf("The count is starting\n");
for (i = 0; i < 5; i++) {
printf("* ");
sleep(1);
}
printf("Finished!");
srand(time(NULL));

for (i = 0; i < 100; i++) {
voters[i] = rand() % 6;
printf("%i\n", voters[i]);
}

for (int x = 0; x < 100; x++) {
for (int y
= x + 1; y < 100; y++) {
if (voters[x] > voters[y]) {
temp = voters[x];
voters[x] = voters[y];
voters[y] = temp;
}
}
}
for (i = 0; i < 100; i++) {
printf("%d", voters[i]);
}

for (i = 0; i < 100; i++) {
count = -1;
for (j = i + 1; j < 100; j++) {

if (voters[j] == voters[i]) {
count++;


freq[j] = visited;
}

freq[i] = visited;
freq[i] = count;

}
}
printf("\n Election results: \n");


for (i = 0; i <6; i++) {


printf("%i people voted for %s \n", freq[i], parties[i]);
exit = 1;


}
}


}}
0

I still can't reproduce the issue:

Please send all the requested materials (the entire project, the screenshot of your toolchain and the debugger log) to the email clion-support at jetbrains.com.

0

Please sign in to leave a comment.