Questions tagged [c]

1099972 questions
0

votes
0

answer
7

Views

Is there any best book or site to modify unreal engine source code?

I am trying to modify unreal engine source code, but it is very complex. Is there any best book or site to modify unreal engine source code? I want something like unreal engine code architecture or modifying source code. I already have knowledge of (c++, graphics code [opengl,directx,shader code] an...
casualprogramming
0

votes
0

answer
11

Views

MSVC compiler intrinsic for launching a software interrupt

Is there a compiler intrinsic for x86 software interrupt instructions other than 0x2C in MSVC2017 (x64)? The intrinsic for int 0x2C is __int2c().
PhantomR
0

votes
0

answer
15

Views

Connecting to a SQL Server Database over a network programatically

I am attempting to connect to a SQL Server instance on a remote computer over the network. I have an IP address, a port, the name of the database, a username, and a password. I am attempting to use the Microsoft stock SQL functions (i.e. SQLConnect, SQLPrepare, SQLExecute, etc) My code looks like th...
B Stanton
0

votes
0

answer
8

Views

How to migrate Yelp Fusion API from v2 to v3 in C#

Can someone help me change my c# code to adjust to the yelp fusion v3 changes I have tried changing the version from v2 to v3 in the path. But I am confused on how to do the authentication. Translating to v3, Yelp no longer uses OAuth to Authenticate requests. I have a new API key for v3 but don't...
Nirmal Mulji
0

votes
0

answer
7

Views

How to add individual rounded corners on an Image Control

I'm having issues on how i can individually set the corners of an Image Control (or any control that is inside the Window Control). Using tags adds another pixel or border inside the outer border which is the opposite of what i want - the outer and inner border should merge where it would overlap....
Nii
1

votes
1

answer
115

Views

How to map a decoded buffer from ffmpeg into QVideoFrame?

I'm trying to put by decoded ffmpeg buffer into a QFrame so I can put this frame into a QAbstractVideoBuffer and then but this buffer into a QMediaPlayer. Here's the code for the VideoSurface. According to QT's documentation, I just have to implement these two functions: constructor and bool presen...
Lucas Zanella
2

votes
0

answer
22

Views

How to use QAction to turn a specific QTableView column from format A to format B

I am trying to use a QAction to turn a specific column of a QTableView into from the current format xxx:xxx into another format (xxx,xxx) and reverse. I prepared a small minimal application that carries exactly the problem I have. The applicartion is formed by: 1) A Main window that carries a QTable...
Linds
3

votes
0

answer
15

Views

How Do you apply a vertex shader in C# for D3D9?

I am trying to write a c# program to apply a vertex shader using SharpDx. I am not sure what are the right functions to call. The purpose of the shader is to make the graphics look a little better because it looks pixelated. I have written the program in c++ and proved that my Vertex shader works. N...
Frank
-2

votes
3

answer
37

Views

code will never execute? while using do/while loop c++

I put a do/while loop in my password function but it doesn't work. I use xcode10 to code c++ and when I use a semicolon after the while statement it shows an error saying code will never execute string password (string g) { string ch = 'hello' ; cout
Vibhor Sagar
51

votes
6

answer
5.2k

Views

Why are std::begin and std::end “not memory safe”?

In this blog post, Eric Niebler states that: What is wrong with std::begin and std::end? Surprise! they are not memory safe. Consider what this code does: extern std::vector get_data(); auto it = std::begin(get_data()); int i = *it; // BOOM std::begin has two overloads for const and non-const lvalu...
Davidbrcz
26

votes
2

answer
971

Views

How do I use concepts in if-constexpr?

How does one use concepts in if constexpr? Given the example below, what would one give to if constexpr to return 1 in case T meets the requirements of integral and else 0? template concept integral = std::is_integral_v; struct X{}; template constexpr auto a () { if constexpr (/* T is integral */) {...
kawillzocken
10

votes
2

answer
578

Views

Using std::apply with variadic packs

I am trying to create a generic class that takes a pack of types, stores them in a tuple, and can apply a function over them. What I tried so far is the following: #include struct Base{ virtual void base_function() = 0; }; template struct A : public Base{ std::tuple as; A(T... pack):as(pack...){};...
sqrtroot
11

votes
2

answer
296

Views

Use of overloaded operator '[]' is ambiguous with template cast operator

The following code compiles well in gcc 7.3.0, but doesn't compiles with clang 6.0.0. #include struct X { X() : x(10) {} int operator[](std::string str) { return x + str[0]; } template operator T() { return x; } // (1) fails only in clang //operator int() { return x; } // (2) fails both in gcc an...
Bhavin Chirag
9

votes
3

answer
256

Views

Read uint8_t from std::stringstream as a numeric type

My understanding is that reading a uint8_t from a stringstream is a problem because the stringstream will interpret the uint8_t as a char. I would like to know how I can read a uint8_t from a stringstream as a numeric type. For instance, the following code: #include #include using namespace std; i...
bremen_matt
11

votes
2

answer
190

Views

Forwarding to an Aggregate Initializer?

It seems to me that aggregate initialization (of suitable types) is not considered a constructor that you can actually call (except a few cases.) As an example, if we have a very simple aggregate type: struct Foo { int x, y; }; then this obviously works: auto p = new Foo {42, 17}; // not 'Foo (42,...
yzt
8

votes
2

answer
242

Views

Why is the value of std::string::max_size “strange”?

I was looking at std::string::max_size and noticed the example: #include #include int main () { std::string str ('Test string'); std::cout
Julius
11

votes
1

answer
152

Views

C - Creating an anonymous struct instance

In this code, a structure is defined as follows: typedef struct { int line; int column; } Pos; And later used this way: Pos get_pos ( int delta ) { ... return ( Pos ){ f->line, f->column + delta }; } The line, return ( Pos ){ f->line, f->column + delta } seems to be creating an anonymous instance of...
Jet Blue
7

votes
2

answer
136

Views

Integral promotion and operator+=

I need to eliminate gcc -Wconversion warnings. For example typedef unsigned short uint16_t; uint16_t a = 1; uint16_t b = 2; b += a; gives warning: conversion to 'uint16_t {aka short unsigned int}' from 'int' may alter its value [-Wconversion] b += a; ~~^~~~ I can eliminate this by uint16_t a = 1...
bencemeszaros
1

votes
3

answer
548

Views

visual studio: tell in part of the code to don't exception-break when debugging

I am debugging exceptions in my code, and I my debugger is set to break when one comes out. I would like my debugging session to exception-break on a certain part of my code and not another, do you know il there is an argument (or other) I could write in my code to tell the debugger to don't excepti...
NicoC
1

votes
2

answer
464

Views

Method chaining without parentheses, how to?

I would like to do a method chain, for example like this: Car myCar = new Car(); // Chaining myCar.config.engine.cylinders('4'); But how do I do the chaining, without using parentheses in 'config' or 'engine'? I can only figure out to do it like this: myCar.config().engine().cylinders('4');
1

votes
3

answer
7.1k

Views

Install SQL Server Silently Using C# Forms Application

I have an windows application developed in C#, I need to install it on a PC which will just have the Operating System and .Net Framework installed. Now I have to give an option to install SQL Server 2008 R2 Express edition on that PC, using this windows application. I have coded for installing/unins...
Rama
1

votes
1

answer
250

Views

infine windows message loop - c++

I tried to create this window class which creates and shows a window. When I run this class, GetMessage keep on sending WM_PAINT message, and task manager shows me about 50% CPU usage just from my process. main.cpp: #include 'Window.h' int WINAPI WinMain( HINSTANCE /* hInstance */, HINSTANCE /* hPre...
user3048787
1

votes
1

answer
223

Views

Virtual Method in a Base class to use a Static variable from a child class

Is it possible for a Virtual Method in a Base class to reference/access/use a Static variable from a child class? Its probably easier to explain in code. In the following example is it possible to make the virtual method Arc::parseFile() look for data_arc? public class Base { public static string DA...
Jake M
-2

votes
0

answer
24

Views

Mocking generic methods in Moq with interface

I am trying to setup moq for the following generic interface but getting exception public interface IReadAccess { Task GetAll(); } var m = new Mock(MockBehavior.Strict); m.Setup(p => p.GetAll()).ReturnsAsync(new List()); m.VerifyAll(); Getting bellow exception Moq.MockException HResult=0x80131500...
Azad
-3

votes
0

answer
24

Views

Using the Write system call with unicode/wchar_t?

I'm trying to figure out how to print a string of characters declared as ... L'test string'. (Essentially trying to imitate prinf's %S) I'm starting by trying to write my own putwchar but am stumped. I've tried the following but I think i'm missing something obvious as it's just returning junk chars...
Finola Cahill
-1

votes
1

answer
25

Views

How to Manage Employee Daily Multiple InTimes, and OutTimes and Calculate Total Hours in Sql Server and C# [on hold]

How to make Time & Attendance application that stores the time is an 'IN' time or 'OUT' time. The application takes the first entry for the Employee /Day to be 'IN', the next one to be 'OUT' , the 3rd one to be 'IN' and so on. I want to write a query to export records with the in and out times for...
Mian Usman
1

votes
2

answer
90

Views

Change user console input as they type in C

I am writing a C program which takes user input. The user input requires some special characters which I want the reserve special keys on the keyboard for. To keep it simple, suppose I want any occurrence of the symbol \ to be replaced with λ. So that if the user types \x.x, they see λx.x. To clar...
Luke Collins
0

votes
0

answer
19

Views

Can you put stack allocated values into a heap allocated array

I was wondering if I had a heap allocated array and I passed it into my function. If I fill the heap allocated array in my function without heap allocating the values (ie. Just assigning values to the heap array) will that create an error, and will I be able to access my heap array values outside of...
FruitCode
0

votes
1

answer
53

Views

how to add new functions to a class whose implementation is not accessible in c++

Is it possible to add new functions in the class if the implementation of this class is hidden to user. But still if its required to add a new function to this class.
LearningCpp
2

votes
3

answer
27

Views

Memory allocation after declaration of extern class variable

I have read in multiple places that when declaring an extern variable, the memory is not designated until the definition is made. I was trying this code which is giving contradictory output in gcc. #include int main(){ extern int a; printf('%lu',sizeof(a)); return 0; } it should have shown error or...
Aditya Gaddhyan
-1

votes
0

answer
13

Views

ReadAsStringAsync().Result Escaping Escape Characters

I have a web service that returns a JSON result. I am consuming this web service in a Xamarin App. When I look at the JSON returned from the web service in Postman, I see that all the double quotes have been escaped (\'). Which I believe is acceptable. In my App, I can successfully communicate wi...
Krisjl
0

votes
1

answer
17

Views

Why the type did not deduced to `const` type in both auto and template function cases? [duplicate]

This question already has an answer here: why auto i = same_const_variable could not deduce “const”? 2 answers This is my first question here and I hope I have added all relevant information to have a minimal verifiable complete program. In case you need more information kindly comment to me. I...
Using
0

votes
1

answer
11

Views

Unit Testing code that uses a separate AppDomain

I have code that uses an AppDomain to dynamically load plugins. I have a private internal class called PluginFinder to do the work. This all works in the production environment, but I am now trying to write MS Unit Tests for it, and I am getting an error saying the assembly could not be found. To be...
Tim
-1

votes
1

answer
15

Views

Passing JSON object to Server side and parsing in function

I am attempting to pass the JSON object to the server side. I have the JSON down, but retrieving it in the function and getting the values from the object is where I am lost. I have tried using a list class and a string. I will show the list and where I got stuck and the string. AJAX: login: functio...
Paradigm
1

votes
5

answer
54

Views

If a base class has private data members that are modified in a member function, how does a derived class use that function?

I'm working on a project to learn about object oriented programming. From what I understand, when a class is derived from a base class, it can access all of the public member functions of the base class. In C++ a public inheritance means that private members cannot be accessed. So what happens when...
CompSciStudent2468
18

votes
7

answer
1.5k

Views

Deleting raw pointers from std::vector

I have following pattern: I have a std::vector containing raw pointers to objects (I know raw pointers are 'evil', but it's legacy software needing to be maintained). Now for each element in the vector I need to do a test and if the test is positive do something with the pointer, delete it and then...
Jabberwocky
0

votes
1

answer
45

Views

Find prime numbers. Prime number form other then 6k+1 6k-1

I'm trying to optimize a prime search algorithm. I have a program that finds (counts actually) primes below some limit. I know that prime number can be expressed in form 6k+1, 6k-1, for some k > 0. For time present I use sieving algorithm to sort non-primes out. Some pseudo code : int P[100] = {1};...
0

votes
0

answer
57

Views

C++: Why are function object base classes, adaptors and binders deprecated(C++11) and removed(C++17)? [duplicate]

This question already has an answer here: Why have unary_function, binary_function been removed from C++11? 2 answers Why std::function::argument_type has been deprecated? 2 answers replacement for binary_function 2 answers Why are function object base classes (unary_function, binary_function), a...
pasha
0

votes
1

answer
43

Views

Trouble whilst creating a while loop

So i was given this question below to answer and I initially created a for loop to do this which worked fine but i was told i could also do it in a while loop which is what i am trying now however i am not sure where I've gone wrong in my code below as i'm getting a indexoutofrange exception. Questi...
Owen Hodgson
-3

votes
0

answer
52

Views

IF + loop statements or split the function?

I basically want to do the following: Create a new carriage Fill the carriage with pets till traincapacity is reached(10). Create a new carriage and fill it with pets again till traincapacity is reached. Is this even possible in one function? or should i split it in two two functions public enum Pet...
David Deng

View additional questions