Mihail
I read that you asked if you have to use Android studio for it
Mihail
So yes you can use it with android studio
Mihail
But you don't have to
Mihail
I haven't worked with it much, so I'd rather not
Mihail
I don't do android development
Anonymous
🐰🐾 سمیه
Segmentation fault (core dumped)
whats this error?
🐰🐾 سمیه
in c
BinaryByter
you are reading memory you shouldn't read
BinaryByter
or writing to
🐰🐾 سمیه
so what should I do
BinaryByter
you are probably reading at a position in the array that is too big for the array
BinaryByter
check for that
Rahul
Run gdb . Exe core
Rahul
Find the error
Ибраги́м
Wow
Rust people claim we've awful error messages, that
Ибраги́м
is getting undone in every release
Ибраги́м
🐰🐾 سمیه
Ok, thanks guys. I'll use gdb
🐰🐾 سمیه
sure, thanks.
🐰🐾 سمیه
https://hastebin.com/epocumogow.cpp
🐰🐾 سمیه
Ибраги́м
Alrighty then
🐰🐾 سمیه
It wants to get a list of numbers, and then another number to check if there is a match for it among the numbers in the list.
Anonymous
that should be "else if" instead of "if", i think
Anonymous
at 2nd if
🐰🐾 سمیه
Ok thanks, I'll correct it.
🐰🐾 سمیه
Anonymous
why are you using else if at 4th if point?
Anonymous
you should use curly bracket in each of if and else commands
🐰🐾 سمیه
The function part was in the book. It checks whether X is in the upper half or the lower half.
olli
BinaryByter
BinaryByter
I realized that
🐰🐾 سمیه
Run gdb . Exe core
I ran "core" command on gdb and got this message:
No core file now.
Anonymous
sorry i am alien😂
Ибраги́м
Starting with
while ( getchar() != EOF )
v[i++] = getchar();
1. getchar() not your friend here, u need to issue it a divorce. what you want here is scanf()
Replace with:
for (i = 0; i < 5; ++i)
{
scanf("%d", &v[i]);
}
PS: my C is ever rusty
Ибраги́м
int main()
{
int i;
extern int v[], x; /// What is the value of x?
printf ("enter a list of numbers:\n");
for (i = 0; i < 5; ++i) {
scanf("%d", &v[i]);
}
/// get the number you want to search
scanf("%d", &x);
/// look for proper binary search here: https://rosettacode.org/wiki/Binary_search#C
printf ("%d", binsearch());
}
Ибраги́м
Look @ Proper Binary search here
https://rosettacode.org/wiki/Binary_search
Ибраги́м
2. Depending on extern, C is every yucky!
🐰🐾 سمیه
🐰🐾 سمیه
thanks🌷🌷🌷
Anonymous
Anonymous
Std::cin.get() I believe the enter key is counted as well right ?
🐰🐾 سمیه
Ибраги́м
🐰🐾 سمیه
2. Let me show you why getchar() is evil in this context:
#include <stdio.h>
int main()
{
int i = getchar();
printf("Printing Character equivalent: %c\n"
"Printing Integer equivalent: %d\n"
,i, i);
}
🐰🐾 سمیه
This part
Anonymous
Hello
Anonymous
I have an issue I need help with
Anonymous
I am using cin.get to take in a character input
Ибраги́м
🐰🐾 سمیه
Ok, I'll do it now
Ибраги́м
Ибраги́м
🐰🐾 سمیه
It prints a character and its ASCII integer value using getchar. So what's the problem with it?
Ибраги́м
Dima
lol
Dima
Ибраги́м
سمیه I'm waiting
🐰🐾 سمیه
🐰🐾 سمیه
Ибраги́м
For what
Slap yourself and post it on https://gfycat.com
Ибраги́м
For what
Because the problem is glaring I'm confused u didn't see it
Ибраги́м
Ибраги́м
Even if u have the best algorithm your input will be wrong most times
🐰🐾 سمیه
I've used getchar and the book has also used it many times, what's wrong with it? 🤷♀
Ибраги́м
Anonymous
The user has 10 try’s to guess a word
Anonymous
The user inputs one letter at a time
Anonymous
This letter variable is a char
Anonymous
When I used std::cin, it ignores spaces , which some of the names they are guessing has two words , so they Are strings and a space input would be needed
Ибраги́м
سمیه
Can't u see I entered 20, it stored 50