[Solved] using goto keyword in C [closed]

If the program really does print 0 for you then there might be a serious problem with your compiler (or even your machine…). My suspicion is that it doesn’t print 0, but your question is really why the program loops infinitely. This is because the if-body only contains the print statement. So when a reaches … Read more

[Solved] How to search a given word in word file by C# [closed]

If you are using the Aspose library as stated in your comment you can achieve this through a customised implementation of the IReplacingCallback interface. bool IsContain(string word, string filePath) { Document doc = new Document(filePath); OccurrencesCounter counter = new OccurrencesCounter(); doc.Range.Replace(new Regex(word), counter, false); return counter.Occurrences > 0; } private class OccurrencesCounter : IReplacingCallback { … Read more

[Solved] Cannot implicitly convert type ‘System.Collections.Generic.IEnumerable’ to ‘System.Collections.Generic.List’ [closed]

Entity Framework has some async methods. You should use ToListAsync() but your method has to return the complete object. When you receive the object returned by the method, then you can use the Select method to get what you want. public async Task<IEnumerable<Intermediary>> GetTest(string company) { var db = new SibaCiidDbContext(); var results = (from … Read more

[Solved] How to add a timeout when reading from `stdin` [closed]

The following program will read from stdin with a timeout, which is what you want. #include <stdio.h> #include <unistd.h> #include <sys/select.h> #define LEN 100 int main() { struct timeval timeout = {3, 0}; fd_set fds; FD_ZERO(&fds); FD_SET(STDIN_FILENO, &fds); printf(“Hi. What is your name?\n”); int ret = select(1, &fds, NULL, NULL, &timeout); if (ret == -1) … Read more

[Solved] How to create a vector of complex numbers in c++? [closed]

Here’s an example I used: double real; double imaginary; std::vector<std::complex<double> > database; //… std::cin >> real; std::cin >> imaginary; const std::complex<double> temp(real, imaginary); database.push_back(temp); In the above example, I read in the real and imaginary components separately. Next, I create a temporary complex object using the real and imaginary components. Finally, I push_back the value … Read more

[Solved] C++ while loop resetting variables?

Moving the line stringstream aa; just before the line aa << b; solves the problem for me. This is perhaps caused by use of aa both as an input stream as well as output stream. Not sure of the details. Update Here’s your program with a bit of error checking code thrown in. #include <iostream> … Read more

[Solved] How to capture value OOPS & Generic [closed]

While looking at your code, why would one want to read class specific properties in a generic method? The only solutions i see is to use Reflection, or create an abstract base class with a before save method and call that method in de Save() method. Add a generic type constraint to the DBObject class … Read more

[Solved] C and C++ : data file with error “Expected unqualified-id” [closed]

OP here. These are the steps I took to resolve my issue, based on the last edit of my question: With the separate files, as given in my question, the error was Expected identifier in mscmix_dat.c. Per @LightnessRacesinOrbit’s suggestion, I consolidated the multiple main.cpp, msclib.h, msclib.c, and mscmix_dat.c files into two files: main.cpp and msclib.c, … Read more

[Solved] Segmentation Fault calling a member function [closed]

a1 is an uninitialized pointer. It does not point anywhere. Using it causes undefined behaviour. You can only dereference pointers that point to valid objects. In your sample code there is actually no way to create a saa since it has protected constructors. You would have to derive a class from saa, create an instance … Read more

[Solved] Can any one please help me what wrong with this code? [closed]

Ok, you dynamically allocate 10 bytes. Then you make the “name” variable (a char pointer) point to that dynamically allocated block. Then you make a char pointer which points to the same dynamically allocated block that “name” points to. Then you “free(name)” which deallocates the block that “tmp_name” also points to. “name” and “tmp_name” both … Read more

[Solved] Periodicity of events 2 [closed]

If you want this to trigger in February, May, August and November, you shouldn’t be subtracting one from the difference. Just use: return (monthDiff % periodicity) == 0; When the months are equal (February), 0 % 3 == 0. When you’re a multiple of three months out (such as August), 6 % 3 == 0. … Read more

[Solved] Bad Data exception during RSA decryption

Among other problems you are assuming that the ciphertext can be converted to UTF-8 meaningfully, and that isn’t guaranteed. If you want to encrypt text and transmit/store the encrypted contents as text you need to follow this pattern: Encrypt(textIn => textOut): Convert textIn to bytesIn via some encoding. UTF-8 is pretty good. Encrypt bytesIn to … Read more