Nyuke
What are opinions about freecodecamp?
professor
Off topic. Github pages or gitbooks for personal blogs coding and stuff ?
Nyuke
/notes
Siddharth Sahoo
Please Help me out .How to debug this error and please also explain me .Below the piece of code I had pasted the error message as well. ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ++ int numberOfOccuence(int Array,int x){ int count=0; for(int k=0;k<10;k++){ if(Array[k]==x) count++; } return count; } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ prog.cpp:20:35: error: invalid conversion from 'int*' to 'int' [-fpermissive] cout<<numberOfOccuence(Array,x); ^ prog.cpp:4:5: note: initializing argument 1 of 'int numberOfOccuence(int, int)' int numberOfOccuence(int Array,int x){ https://pastebin.com/mLhgmGaG
数学の恋人
error is clearly specified
数学の恋人
read it
Siddharth Sahoo
int* to int [-fpermission ] what does this mean ?
Siddharth Sahoo
datatype is miss matched while conversion ?
Siddharth Sahoo
But how to debug this?
Anonymous
First of all, use of 'Array' does not match to what is in function parameters
Anonymous
It's not actually an array
Siddharth Sahoo
pastebin
https://pastebin.com/mLhgmGaG
Siddharth Sahoo
Anonymous
https://pastebin.com/mLhgmGaG
What do you think this code is supposed to do?
Anonymous
What happens at this part?
Siddharth Sahoo
It will take array elements as input.
Anonymous
Suppose you input 10 at first loop iteration. What does it mean? What exactly happens at this part?
Anonymous
Can you answer my question?
Siddharth Sahoo
Anonymous
I'm not sure I follow you there. Can you tell me what is "first iteration"?
Anonymous
You don't seem to want to figure out what's wrong with your code
Anonymous
You just wanted someone to fix the code for you
Siddharth Sahoo
Can you answer my question?
It will take input from the user and will store the input value to the ith index of an array.
Siddharth Sahoo
You just wanted someone to fix the code for you
Roman it's nothing like that.
Anonymous
Can you see an array here?
Siddharth Sahoo
Yeah, that's what I did wrong. I should be writing it as int *Array or int Array[] .Now I know.
Anonymous
Also, 21 line is also wrong. Keep in mind.
Siddharth Sahoo
Also, 21 line is also wrong. Keep in mind.
How come. Spread some light please.
Anonymous
Uh
Anonymous
No
Anonymous
I was wrong
Siddharth Sahoo
It's working fine,my dear friend. See the answer.
Siddharth Sahoo
I was wrong
It's okay.
Anonymous
Sorry. Congratulations.
Siddharth Sahoo
Thanks Roman, for helping me out.
Siddharth Sahoo
Can you help me out in one more thing. Lately I was submitting my solution to SPOJ .This is the question https://www.spoj.com/problems/BSEARCH1/ and I wrote this as my problem solution and it is working fine on my code blocks compiler but unable to get accepted on the SPOJ and stating to be runtime error. Can you give a look to the code. https://pastebin.com/j035fMCX
Siddharth Sahoo
Is it some contest?
No. No. It is not a contest. Do check the problem link, You will also get to know that it is just a simple problem question.I have some other code solution as well on my hand from my friend and it is almost similar to my code. But as I said it is unable to get accepted by SPOj.
ShyBlogger
I'm sorry😭😭
ShyBlogger
Mistake
Siddharth Sahoo
Is it some contest?
So Can you help me ?
klimi
So Can you help me ?
Its just binary search no?
Siddharth Sahoo
Its just binary search no?
Yes it is just a simple binary Search .
Siddharth Sahoo
What if there's more than 100 elements given?
Yeah...Even the constraints of the problem say 0 < N <= 10^5. And if accordingly I make an array with 100000 size. It says the Time exceeded. I did int arr[100000] but no help.
Siddharth Sahoo
Help me out I don't know about this std:vector and all.
Pavel
Help me out I don't know about this std:vector and all.
Here's documentation https://en.cppreference.com/w/cpp/container/vector If something is unclear google it, if it doesn't help then ask with details (what exactly is not clear/not working)
klimi
Help me out I don't know about this std:vector and all.
Use it as vector and if you want to add last item do vector.push_back(item)
Pavel
Use it as vector and if you want to add last item do vector.push_back(item)
This. And I would suggest to call reserve as far as it's future size is known.
klimi
Is it like flag?
Pavel
Yes it is just a simple binary Search .
Also, I think there's something with the algorithm itself, because if it's the binary search then why you have the second for loop. It feels like you're doing it linearly. But it looks even stranger
Siddharth Sahoo
Also, I think there's something with the algorithm itself, because if it's the binary search then why you have the second for loop. It feels like you're doing it linearly. But it looks even stranger
while(left<=right){ mid=(left + right)/2; if(array[mid]==query) { result=mid; break; } else if(array[mid]>query) right=mid-1; else left=mid+1; } cout<<result<<endl; } No it was binary search. See.
Pavel
Is it like flag?
This allocates chunk of memory that can hold the asked amount of elements. So when you do push_back it doesn't call for additional reallocations
klimi
Yeag
klimi
I know how storing stuff In memory works
klimi
Its pretty clever to have such function
Anonymous
Or just use realloc.
However it requires some experience with the allocated storage duration and is used in C. Using vectors would be much simpler way.
Siddharth Sahoo
Siddharth Sahoo
Its okay. You don't need to be sorry for anything.I guess that's why we are here to learn and adopt new good habits.
MrSmith
Hi. A have strange error with my project
MrSmith
https://github.com/razor-team/razor-phantom/tree/barebones-desing
MrSmith
Maybe i shoul manyally set order of obj file should linking?
n1coc4cola
what's the ide you use?
n1coc4cola
If you use Qt, you can have some errors with the library of the others or somethings which works not as you want
n1coc4cola
I had a problem of linking objects (like you) when I wanted to compile it in the ide of Qt
n1coc4cola
Nox, I run the commands manually and I have no problem
n1coc4cola
maybe you should do this (for me it was with the 'make' command)