[Solved] Evaluating C binary operations

k=25; ++k; k++; k|7&12; After the first 3 lines, k is 27. In the fourth expression, the bitwise AND operator & has higher precedence than the bitwise OR operator |, so it is equivalent to 27|(7&12); Converting the values to binary gives us 11011|(00111&01100); The inner part evaluates to 00100, then 11011|00100 evaluates to 11111, … Read more

[Solved] Why does incrementing a pointer work, but treating it as an array fail? Part 2 [closed]

I’m not sure what your question is, but this code probably doesn’t do what you want: printf(“main Pointer to struct.” EOL); for (int i=0; i<count; i++) { printf(“index: %d useless1: %d” EOL, i, b->useless1); printf(“index: %d useless2: %d” EOL, i, b->useless2); b++; } printf(EOL); printf(“main Index into array of structures.” EOL); for (int i=0; i<count; … Read more

[Solved] Calling methods in java and C# [closed]

Can we call a method in java or C# like this without parameters but separated with commas: No you can’t. According to the method’s signature there are expected 3 integer literals. That being said, you can’t call it this way. Regarding the C#, you could define a, b and c as optional int, like below: … Read more

[Solved] Impossible declare string type in C++

The hint is in the warnings: the #include <string> is ignored because it’s apparently after the include of the precompiled header file. Make sure the precompiled header is included first. Background: If the corresponding project setting is enabled, the Visual C++ Compiler will, in a pre-preprocesser step, replace the line #include “stdafx.h” (this is the … Read more

[Solved] C# BigInteger remainder as fraction

This seems to work: BigInteger a = new(5678); BigInteger b = new(1234); BigInteger div = BigInteger.DivRem(a, b, out BigInteger rem); var decimalDigits = new List<BigInteger>(); while (rem != 0 && decimalDigits.Count < 10) { rem *= 10; decimalDigits.Add(BigInteger.DivRem(rem, b, out rem)); } Console.WriteLine($”{div}.{string.Concat(decimalDigits)}”); This is pretty much just an implementation of long division. 1 solved … Read more

[Solved] Find if string is in other string

I think you are looking for something like this class Program { static void Main(string[] args) { string attrs = “AAA,BBB,CCC,DDD”; List<Vehicle> vehiclesSort = new List<Vehicle>(); vehiclesSort.Add(new Vehicle(attrs)); vehiclesSort.Add(new Vehicle(“bbb”)); vehiclesSort = vehiclesSort.Where(o => o.attr.Contains(attrs)).ToList(); foreach (var VARIABLE in vehiclesSort) { Console.WriteLine(VARIABLE.attr); } } } public class Vehicle { public Vehicle(string attr1) { this.attr = … Read more

[Solved] Push pop stack operation in C [closed]

Here you have again some things wrong. Before you create new threads with similar content, stick to one thread. In your code you also never check if malloc fails. It’s always better to do that. For simplicity I’ve omitted these checks in my suggestions. 1. Why do you do S1[0].top=-1; in makeEmpty? create already does … Read more

[Solved] How to access RichTextBox.Select() method while referring to it as a “Control”

private void TextSelectionAtSomePoint() { int selectionStart = 0; int selectionEnd = 6; var temp = tbcPages.Controls[0].Controls[0] as RichTextBox; if(temp != null) temp.Select(selectionStart,selectionEnd); } UPDATE: As @JonSkeet said in comments, seems the OP expects a RichTextBox here; so if it’s not, it really should throw an InvalidCastException, not just ignore it. So, I update the answer … Read more

[Solved] Split line from txt file

public static String[] SplitCsv(String value) { if (Object.ReferenceEquals(null, value)) return null; const Char quotation = ‘\”‘; const Char separator=”,”; List<String> result = new List<String>(); Boolean inQuotation = false; Boolean isStarted = false; StringBuilder Sb = new StringBuilder(); foreach (Char Ch in value) { if (inQuotation) { Sb.Append(Ch); inQuotation = Ch != quotation; continue; } if … Read more

[Solved] ambiguous overload C++ for operator = [closed]

if (dungeonLevel = “1”) This is the line causing the error. You want it to be: if (dungeonLevel == 1) There are 2 changes I have made here: Firstly, I replaced the = sign, called the assignment operator, with the == sign, which is the comparison operator. The assignment operator is used when you assign … Read more