[Solved] How to run gcc compiler from my qt application? [closed]

[ad_1] You can run any program from Qt5 and capture it’s standard output using the QProcess class. The official documentation with examples is here: http://doc.qt.io/qt-5/qprocess.html So what I would do then is simply make a GUI with 2 QTextEdit widgets, one for the code and one for the compile/run output. Documentation for QTextEdit is here: … Read more

[Solved] Obfuscated C recursion Code Please explain [closed]

[ad_1] Theoreticaly and doing it in paper: f(1,2,2)->return f(1-1,f(1,2,2-1),f(1,2,2-1)+2) Then we do the internal Both are the same f(1,2,2-1) -> return f(0,f(1,2,1-1),f(1,2,1-1)+1) again the internal Again both are the same -> return 2 (x=2); so we go back return f(0, f(1,2,1-1) -> 2, f(1,2,1-1) ->2+1) -> f(0, 2, 3) -> return 2+3(x+y); Again back f(0, … Read more

[Solved] How are pointers stored in memory?

[ad_1] C11, 6.3.2.3, paragraphs 5 and 6: An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, might not be correctly aligned, might not point to an entity of the referenced type, and might be a trap representation. Any pointer type may be converted to an integer type. … Read more

[Solved] How can I open application using C# from port 9999 [closed]

[ad_1] you could try this private void SendToServer(IPAddress IP, int Port) { try { TcpClient tcpclnt = new TcpClient(); tcpclnt.Connect(IP, Port); //your code here } UPDATE For the server you’ll use this public static void Main() { TcpListener serverSocket = new TcpListener(9999); TcpClient clientSocket = default(TcpClient); int counter = 0; serverSocket.Start(); Console.WriteLine(” >> ” + … Read more

[Solved] Getting Infinite Loop Issue. Process Terminated due to StackOverflowException?

[ad_1] In class2, you are calling Console.WriteLine(c1.inf1());. So class1.inf1 should return a string as you are trying to output it to the console. However, class1.inf1() recursively calls itself with no exit and does not return a string. So I think this may be what you are trying to accomplish: protected internal string inf1() { return … Read more

[Solved] calculate frequency of each letter in a string

[ad_1] There are two problems here. First, while std::string is null-terminated (required in C++11, de facto in most implementations before that), you cannot access past size(). If you used string::at() directly, then you’d get hit: reference at(size_type pos);      Throws: out_of_range if pos >= size() which would be true for the null terminator. So the right … Read more

[Solved] Passing map (matrix) to class C++ [closed]

[ad_1] Try using Boost.MultiArray. It allows you to create multidimensional arrays with contents of arbitrary content type. I have used it (the boost::multi_array_ref part to be more specific) and it works pretty nice. An important feature is the ability to create array views (and slices based on views). [ad_2] solved Passing map (matrix) to class … Read more

[Solved] C++: Can’t understand this code

[ad_1] typedef typename vector<Location>::iterator iterator; This defines a new type alias iterator which maps to vector<Location>::iterator. The typedef itself isn’t actually used in this piece of code though. unordered_map<Location, vector<Location> > edges; This defines an std::unordered_map http://www.cplusplus.com/reference/unordered_map/unordered_map/ edges in which Location (which is the templated type) is the Key value and an std::vector of Locations … Read more

[Solved] Convert string Time format to Time format [closed]

[ad_1] You can try ParseExact method to convert a custom string to a DateTime, then use ToString method to convert it to your desired string format. var result = DateTime.ParseExact(“10:30AM”, “hh:mmtt”, CultureInfo.InvariantCulture) .ToString(“hh:mm:ss tt”); //result : “10:30:00 AM” In the DateTime formatting you may remember these notes: hh: hour part mm: minute part ss: second … Read more

[Solved] Copying local file to network shared drive issues

[ad_1] Ok, let’s work on this code a little. First let’s simplify building the paths. We have a network path and a local path. According to your current code the network path is built with a few variables comboBox1, comboBox2, and Environment.UserName, so let’s do it a little different: var networkPath = Path.Combine(@”\\network”, comboBox1.SelectedItem as … Read more

[Solved] function to calculate the sum of odd numbers in a given stack [closed]

[ad_1] just an example, you could pass your stack variable as an argument to the GetSum() function. private static int GetSum() { Stack<int> stack = new Stack<int>(); stack.Push(2); stack.Push(5); stack.Push(7); stack.Push(4); stack.Push(1); int sum = 0; foreach (int number in stack) { if (number % 2 != 0) { sum += number; } } return … Read more