[Solved] c++ fgets Segmentation fault (core dumped)

It turns out that fd/fopen was not getting initialized on line 396 The modified code below allowed my program to run: Here is the code: 393: FILE *fd; 394: char fd_name[512]; 395: strcpy(fd_name,npb_list[freq][app][thread].file_name); 396: fd = fopen( fd_name, “r”); // <<- change made to this line 397: cout << “fd_name = ” << fd_name << … Read more

[Solved] how to make thread in c++

_beginthread is a Visual C++ CRT function. I don’t recommend using it or process.h for this purpose. Please use std::thread (or if your compiler is older, boost::thread). If you were using _beginthread, you’d give it tdrow, not tdrow(). 1 solved how to make thread in c++

[Solved] What does below pointer syntax mean [duplicate]

The three are same. The only differences are, The position of the asterisk and the whitespace around them(which is done according to one’s preference) The string literals “blah” could be stored in the same memory location or different locations. From the C11 standard, 6.4.5 String literals […] It is unspecified whether these arrays are distinct … Read more

[Solved] extracting power from polynomials

Problems: If the user enters something that doesn’t contain a ‘^’, then your code exhibits Undefined Behavior as num is not initialized here if(isdigit(num)) If the input does contain a ‘^’, then the if will be true. Here: strcat(power,parts[k]); strcat finds the NUL-terminator in its first argument and overwrites its second argument from that position. … Read more

[Solved] Why does the array keep reverting to 0

You declare unsigned short hex_v_info (2 bytes on my system), then read data from with fscanf(fp ,”%x”, &hex_v_info) where the format string %x expect the address of an int (4 bytes on my system). This will certainly overwrite data unexpectedly. unsigned short **v_info but you store an array of int [s_votes]. If your pointers are … Read more

[Solved] Get specific data from a string? C#

I solved it!! Thank your comments and suggestions..I’ll improve the way I question.. HAHAH I hope you guys and gals get the logic. Quite simple 🙂 string group = “|17|11|05|”; string[] words = group.Split(‘|’); foreach (string word in words) { if (word.ToString() != “”) { string cg = word; } } 1 solved Get specific … Read more

[Solved] simple calculator that shows the different between 2 numbers in C# [closed]

Write this code in the click event of calculate button private void Calculate_Click(object sender, EventArgs e) { if (textBox1.Text != “” && textBox2.Text != “”) { int diff = (Convert.ToInt32(textBox1.Text) – Convert.ToInt32(textBox2.Text)); textBox3.Text = diff.ToString(); if (diff >= 0) { textBox3.ForeColor = Color.Green; } else textBox3.ForeColor = Color.Red; } else { MessageBox.Show(“PLZ Enter the balances”); … Read more

[Solved] On do statement [closed]

In the C specification the do iteration statement is written alone, not as do/while. This is not correct. C11 6.8.5 Iteration statements: iteration-statement: while ( expression ) statement do statement while ( expression ) ; … Why, maybe because are they, in that context, two separate statements? No, do-while is one statement as specified by … Read more

[Solved] Unterminating c++ Program [closed]

You are calling the MathContext constructor-methods directly, change that to to the below by dropping the first part of MathContext::MathContext to just MathContext int main(int argc, _TCHAR* argv[]) { MathContext context[8]; context[0] = MathContext(); context[1] = MathContext((unsigned short) 46); context[2] = MathContext((unsigned int) 20); context[3] = MathContext(MathContext::UP); context[4] = MathContext((unsigned short) 36, (unsigned int) 30); … Read more

[Solved] how to return value as array object [closed]

Hope that you can try like this: return a.GroupBy(v => v).Select(x=> x.Key + x.Count()).ToArray(); If you are expecting sum of each key and count of elements associated with that keys in the result array. Please Go through this example, and let me know your result is different than this: The method signature will be changed … Read more