15,990,993 members
Home / Discussions / C / C++ / MFC

C / C++ / MFC

 Re: i would like to be a programmer Vaclav_30-May-18 9:19 Vaclav_ 30-May-18 9:19
 Re: i would like to be a programmer Tarun Jha5-Jun-18 10:53 Tarun Jha 5-Jun-18 10:53
 try /catch Exception missing type Vaclav_29-May-18 4:00 Vaclav_ 29-May-18 4:00
 Re: try /catch Exception missing type Jochen Arndt29-May-18 5:09 Jochen Arndt 29-May-18 5:09
 Re: try /catch Exception missing type Richard MacCutchan29-May-18 5:12 Richard MacCutchan 29-May-18 5:12
 Re: try /catch Exception missing type SOLVED Vaclav_30-May-18 9:06 Vaclav_ 30-May-18 9:06
 Re: try /catch Exception missing type SOLVED leon de boer30-May-18 16:25 leon de boer 30-May-18 16:25
 how to correct an segmentation fault ? Tarun Jha26-May-18 11:55 Tarun Jha 26-May-18 11:55
 below is an hackerrank question link where i am encountering an segmentation falut. HackerRank[^] and this is my solution ```#include #include using namespace std; void fillVector(vector &temp, unsigned long number); void RotateVector(vector &arr1, vector &arr2, unsigned long k); int main(){ unsigned long n,k,q; cin >> n >> k >> q; vector a, b; fillVector(a, n); fillVector(b, q); RotateVector(a, b, k); return 0; } //to rotate the vector by kth measure. void RotateVector(vector &arr1, vector &arr2, unsigned long k){ unsigned long arraySize = arr1.size(); unsigned long querySize = arr2.size(); unsigned long rotation = k, i; unsigned long start = rotation%arraySize; //this was causing the problem. if(rotation rotatedArray; for(i=0; i &arr, unsigned long n){ unsigned long temp; for(int i=0; i> temp; arr.push_back(temp); } }``` the above solution is giving segmentation fault and i am not able to detect it.(rest all the test-cases are passed) here are the links to that test case inputs : https://hr-testcases-us-east-1.s3.amazonaws.com/1884/input04.txt?AWSAccessKeyId=AKIAJ4WZFDFQTZRGO3QA&Expires=1527377038&Signature=sA5C43bnnqyLeXwWA9L16en3rEE%3D&response-content-type=text%2Fplain and expected outputs : https://hr-testcases-us-east-1.s3.amazonaws.com/1884/output04.txt?AWSAccessKeyId=AKIAJ4WZFDFQTZRGO3QA&Expires=1527377042&Signature=%2BSyDUj0B5DwySkSPGjiwfmB7MlE%3D&response-content-type=text%2Fplain Edit : Below is the working code: ```#include using namespace std; void fillVector(vector &temp, unsigned long number); void RotateVector(vector &arr1, vector &arr2, unsigned long k); int main(){ unsigned long n,k,q; cin >> n >> k >> q; vector a, b; fillVector(a, n); fillVector(b, q); RotateVector(a, b, k); return 0; } //to rotate the vector by kth measure. void RotateVector(vector &arr1, vector &arr2, unsigned long k){ unsigned long arraySize = arr1.size(); unsigned long querySize = arr2.size(); unsigned long rotation = k, i; unsigned long start = rotation%arraySize; if(rotation rotatedArray; for(i=0; i &arr, unsigned long n){ unsigned long temp; for(int i=0; i> temp; arr.push_back(temp); } }``` Thank you.modified 6-Jun-18 1:05am.
 Re: how to correct an segmentation fault ? Richard MacCutchan26-May-18 21:10 Richard MacCutchan 26-May-18 21:10
 Re: how to correct an segmentation fault ? CPallini29-May-18 0:01 CPallini 29-May-18 0:01
 Re: how to correct an segmentation fault ? Tarun Jha5-Jun-18 1:50 Tarun Jha 5-Jun-18 1:50
 Graphical representation of Data sree7926-May-18 1:09 sree79 26-May-18 1:09
 Re: Graphical representation of Data Richard MacCutchan26-May-18 2:41 Richard MacCutchan 26-May-18 2:41
 Re: Graphical representation of Data leon de boer26-May-18 5:09 leon de boer 26-May-18 5:09
 Re: Graphical representation of Data sree7927-May-18 17:44 sree79 27-May-18 17:44
 volatile issue - repost Vaclav_22-May-18 5:24 Vaclav_ 22-May-18 5:24
 Re: volatile issue - repost Richard MacCutchan22-May-18 8:26 Richard MacCutchan 22-May-18 8:26
 Re: volatile issue - repost CPallini22-May-18 10:11 CPallini 22-May-18 10:11
 Re: volatile issue - repost leon de boer22-May-18 19:12 leon de boer 22-May-18 19:12
 Re: volatile issue - repost CPallini22-May-18 21:39 CPallini 22-May-18 21:39
 Re: volatile issue - repost CPallini22-May-18 10:11 CPallini 22-May-18 10:11
 Re: volatile issue - repost Vaclav_22-May-18 11:54 Vaclav_ 22-May-18 11:54
 Re: volatile issue - repost leon de boer22-May-18 15:44 leon de boer 22-May-18 15:44
 Re: volatile issue - repost Vaclav_22-May-18 17:44 Vaclav_ 22-May-18 17:44
 Re: volatile issue - repost leon de boer22-May-18 18:13 leon de boer 22-May-18 18:13
 Last Visit: 31-Dec-99 18:00     Last Update: 7-Sep-24 5:17 Refresh ᐊ Prev1...289290291292293294295296297298 Next ᐅ