[Solved] Why does the error keep stating incompatible integer to pointer in C for an array?

Based on the phrasing of your question, I’m guessing that you are unfamiliar with the concept of pointers. In C, pointer is a type that stores the memory address of another variable. The & operator retrieves the memory address of a variable. int i = 4; // < An integer variable equal to 4 int* … Read more

[Solved] c language temperature converter : fahrenheit to celcius [closed]

Doing this: celcius=(ferenheit-32)*(5.0/9.0); Does not mean that the value of celcius will always be (ferenheit-32)*(5.0/9.0), anytime that ferenheit changes. What is does mean is that it sets celcius to (ferenheit-32)*(5.0/9.0) at the time the statement is encountered. Since ferenheit doesn’t have value yet when this statement runs, the value of celcius is indeterminate. You need … Read more

[Solved] Open a pgm image 16 bpp [closed]

i’ve found solution to my problem. here is the right code if it can be useful for someone: #include “pgm.h” #include <iterator> #include <algorithm> #include <fstream> #include <sstream> using namespace std; bool convert16to8bit(const std::string& inFilename, mat<uint8_t>& img, const std::string& outFilename){ mat<uint16_t> imgTemp; ifstream is(inFilename, ios::binary); if (!is) return false; string magic; is >> magic; if … Read more

[Solved] Getting a word or sub string from main string when char ‘\’ from RHS is found and then erase rest

To erase the part of a string, you have to find where is that part begins and ends. Finding somethig inside an std::string is very easy because the class have six buit-in methods for this (std::string::find_first_of, std::string::find_last_of, etc.). Here is a small example of how your problem can be solved: #include <iostream> #include <string> int … Read more

[Solved] Upper case the first letter of some words

To set to lower all the words below some length, you can split the words, and depending on its length set it to lower case. In this example i split on a space ” “,if there’s a possibility of another separators this would get more complicated: string unidade = “DIREÇÃO DE ANÁLISE E GESTÃO DA … Read more

[Solved] Trying to make a console application run at 20 frames per second [closed]

You don’t want DateTime.Now.Millisecond, you want the total milliseconds: private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var totalMilliseconds = DateTime.Now.ToUniversalTime().Subtract(Epoch).TotalMilliseconds 5 solved Trying to make a console application run at 20 frames per second [closed]

[Solved] need help in Char array that auto grow

You are not null-terminating the arrays you create. Try this instead: char* dynamicmem(char size) { char* temp = new char[size + 1]; temp[size] = ‘\0’; return temp; } char* regrow(char* ptr, int size, char c) { char *p = dynamicmem(size + 1); for (int i = 0; i < size; i++) { p[i] = ptr[i]; … Read more

[Solved] Write a program to elaborate the concept of function overloading using pointers as a function arguments? [closed]

As the comments stated, it’s not entirely clear where your problem is. It would be nice if you included an example for what you want to understand better, anyway, here’s an example: #include <iostream> void foo(int x) { std::cout << x << std::endl; } void foo(int* x) { std::cout << (*x + 1) << std::endl; … Read more

[Solved] Cuda compilation error: class template has already been defined

I have posted the same post in Nvidia CUDA forum: Link Here I reinstalled multiple times with the method from the post but still having the same “class template” problems. Then I reinstalled CUDA 9.1 and VS2017 ver 15.6.7 also with the same method and it finally works. Further problems that I encountered is in … Read more

[Solved] convert point form decimal to octal in c++?

int deci, rem, octal=0, i=1; float de, x,y,point,rem1; cout<<“enter the decimal”<<endl; cin>>deci; Since deci is declared as int cin>>deci and entering ‘12.5’ will set deci to 12 BTW I assume the next line is a transcription typo deci=y doesnt make any sense at all. I assume you mean y = deci Solution – declare deci … Read more