[Solved] add user input in database [duplicate]

[ad_1] Well first of all you don’t have quotes around your string. You’re also missing a plus sign. It should be like: string sql1 = “insert into items values ( ‘” + this.name + “‘)”; However, this is a really bad way of handling your SQL queries through C#. You should be using parameterized queries! … Read more

[Solved] Finding the most frequently repeated words in the paragraph in c#

[ad_1] In regards to the suffix, this just looks for an s, you can modify to look for other suffixes. string words = “go bread John yesterday going is music musics”; List<string> wordroots = words.Split(new [] {” “}, StringSplitOptions.RemoveEmptyEntries).ToList(); var rootcount = wordroots .Select(wr => { if (wr.EndsWith(“s”)) wr = wr.Substring(0, wr.Length – 1); return … Read more

[Solved] C programming language help me?

[ad_1] Your summation is wrong: s+=((2*i-1) -2*i ); gives -1. You need: s+=i*(2*(i%2) – 1); It will give “-” to all even i‘s and “+” to all odd i‘s. And since you are dealing with whole numbers only, i should be int, as well as all other variables you use: #include <stdio.h> int main () … Read more

[Solved] How to prevent method from running in multiple instances [closed]

[ad_1] I would use Mutex to avoid multiple access to the same recourses. Here you have a brief piece of code to achieve this Mutex mutex; private void StartPolling() { mutex = new Mutex(true, “same_name_in_here”, out bool createdNew); if (!createdNew) { throw new Exception(“Polling running in other process”); } //now StartPolling can not be called … Read more

[Solved] where is the extern file in C++

[ad_1] It’s in one of your compiler’s search paths, or perhaps it does not exist in which case your code probably will not compile. On *nix systems, the search paths are usually /usr/include, perhaps some compiler-specific paths, and any number of paths you gave to your compiler via -I options or similar when you invoked … Read more

[Solved] First time working with exceptions. I’m having difficulty understanding exceptions [closed]

[ad_1] You need a ‘throw’ clause to throw an exception. Maybe you’ll get what you want if you change ‘launchException’ to: void launchException() override { std::cout << customInt << std::endl; std::cout << customStr << std::endl; throw CustomException(customInt, customStr); } Also note the ‘override’ keyword. It may help avoiding the warnings you mentioned in the comments. … Read more

[Solved] Proper use of memory with dynamic array lengths in c++

[ad_1] I’m not sure what you mean by “correct”; your code is not correct at least in the sense mentione by @SamVarshavchik, and which a compiler will tell you about: a.cpp: In function ‘int getFifoData(unsigned char*)’: a.cpp:20:29: warning: ISO C++ forbids variable length array ‘tBuff’ [-Wvla] uint8_t tBuff[txBuf.size()]; If you want to understand why C++ … Read more

[Solved] What main(++i) will return in C

[ad_1] First of all, the declaration of main() is supposed to be int main(int argc, char **argv). You cannot modify that. Even if your code compiles, the system will call main() the way it is supposed to be called, with the first parameter being the number of parameters of your program (1 if no parameter … Read more

[Solved] Difference between 2 floats [closed]

[ad_1] The result is correct. Try to visualize it: Distance between -110 and 100 is the sum of distance between -110 and 0 (Mathf.Abs(-110 – 0) = 110) and distance between 100 and 0 (Mathf.Abs(100 – 0) = 100). That is: 110 + 100 = 210. Perhaps you have a different operation in mind? If … Read more

[Solved] Loop is not working C#.net

[ad_1] Why not just update all after the id that was removed? Like that you don’t need a while, and performance will go up 300%. update questions set no = no – 1 where no > @yourRemovedID [ad_2] solved Loop is not working C#.net