Anonymous
they won't scan and add file with .h
Anonymous
why I can't change like that
Anonymous
target_link_libraries(main
${PROJECT_SOURCE_DIR}/libs/libglfw3.a
${PROJECT_SOURCE_DIR}/libs/libjsoncpp.a
${PROJECT_SOURCE_DIR}/libs/libjsoncpp.dll.a
opengl32)
Anonymous
link_directories(${PROJECT_SOURCE_DIR}/libs)
target_link_libraries(main
libglfw3.a
libjsoncpp.a
libjsoncpp.dll.a
opengl32)
Jagadeesh
int funct1(int a)
{
if(a)
return funct1(--a)+a;
else
return 0;
}
int main()
{
int a=7;
printf("%d",funct1(a));
return 0;
}
Jagadeesh
can anyone explain how it's printing 21
Anonymous
#include <iostream>
int main()
{
int a = 7;
a = (--a) + a;
printf("%d", a);
}
\Device\NUL
Anonymous
it does work
Anonymous
when --a
Anonymous
a become 6(both two)
Anonymous
you can have a try
\Device\NUL
6 + 5 + 4 + 3 + 2 + 1 + 0
Jagadeesh
I use Arch
Ludovic 'Archivist'
Ammar
Or is this the same with context switch that the OS is obliged to follow?
Anonymous
Hello,
I am Hossein, a doctoral researcher at the University of Padova, Italy.
With the aid of the University of Padova and NXP Semiconductor, we started a project similar to the Unreal Engine for programming micro-controllers in Italy. Are you interested in helping us with it?
Anonymous
How are you doing
Anonymous
How are you doing today
.
Anonymous
Ok were are you located in
Anonymous
Anonymous
Abuja Nigeria
Ammar
Anonymous
I live in Abuja
I don't
why do we need two pointers here(*(uintptr_t*))?
Anton
Hi everyone. I need help with static variable that is written in C.
The purpose of the function is to concatenate "abc" string twice to static variable store. On second foo() call I remove the value that was written in the previous call. I already found out that you cannot check whether the variable was initialized or not. I need some work around here, preferably with temporary string in init. Second static variables, global variables, and sentinel values are not allowed.
Desired output: "abc\nabcabc\n". Current output "abc\nabc\n".
void init(char **store)
{
(*store) = (char *)malloc(sizeof(char));
(*store)[0] = '\0';
}
int foo()
{
static char *store;
char *string;
string = "abc";
init(&store);
store = strcat(store, string);
printf("%s\n", store);
}
int main()
{
foo();
foo();
}
Ammar
Anton
Ammar
Ammar
Practically, you should also free() anything you malloc()'ed.
Ammar
Anton
Anton
Ammar
I'll fix the code and come back to it.
Ok, you're good. For what it's worth, I fixed your code. I don't think there is a chance to call free() here. But let's assume memory leak is acceptable for this case.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void init(char **pp)
{
if (*pp != NULL) {
*pp = realloc(*pp, strlen(*pp) * 2 + 1);
} else {
*pp = malloc(4);
(*pp)[0] = '\0';
}
}
void foo(void)
{
static char *store;
init(&store);
strcat(store, "abc");
printf("%s\n", store);
}
int main(void)
{
foo();
foo();
return 0;
}
Ammar
Anton
I don't
ive already understood, ty
Diego
I want to program a serial terminal with a easy user interface for Windows. I never used C++ before. I was checking and Qt could be a good option for it. What do you think?
Ashish
hello guys ,can anyone please help me using graphics.h in code block its kinda urgent
Anonymous
Hi i need help fast
Anonymous
How is the programme structure for creating a tree that has n high and in the right ir is written the numbers from 1 to the file number
Anonymous
And in the left the letters
Anonymous
Its form is a trangule
Anonymous
Example: n=3
1
A12
BC123
YVEF
Hi. Is anybody tried to setup Boost.TestExplorer in VSCode?
klimi
warning: control reaches end of non-void function [-Wreturn-type]
18 | }
Juli
Can anyone help me
Juli
#include <iostream>
using namespace std;
void main (void)
{
static int N = 10;
int counter, sum, number;
cout << " Enter a Positive Integer smaller"
<< " or equal to 10 (the counter) ";
cin >> counter;
cout << endl;
sum = 0;
do
{
cout << " Enter a Positive Integer " ;
cin >> number;
cout << endl;
sum = sum + number;
counter ++;
} while ( counter < N );
cout << " The sum of the digits you have entered is = " << sum << endl;
if ( ( sum % 2 ) == 0 )
cout << " " << sum << " is divisible by 2 " << endl;
else
cout << " " << sum << " is not divisible by 2 " << endl;
// note here no need of return anything
// because the return type of ' main ' is ' void '
} // end of main
Juli
Basiclly i nedd to replace the do {  } while ( ) loop with a for loop
Anonymous
\Device\NUL
Sebas Tian
Sebas Tian
Anonymous
Having said that, it is always a better idea to use void in C when you want to convey that a function has an empty parameter list.
\Device\NUL
соня
Hi guys :)
I have to create accdb using ADO with c++
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace rename("EOF", "adoEOF")
#include <iostream>
using namespace std;
int main(){
CoInitialize(NULL);
setlocale(LC_ALL, "Russian");
try {
_bstr_t scon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\DB\\CPP\\test.accdb";
_ConnectionPtr con("ADODB.Connection");
con.CreateInstance(__uuidof(Connection));
con->Open(scon, (_bstr_t)"", (_bstr_t)"", adConnectUnspecified);
_bstr_t strCmd = "INSERT INTO Employees(EmployeeID, FirstName, LastName, HireDate, City, Country) VALUES(10, 'Mary', 'Williams', '15/4/1993 12:00:00', 'New York', 'USA')";
con->Execute(strCmd, NULL, adCmdText);
con->Close();
}
catch (_com_error& e) {
cout << e.Description();
}
::CoUninitialize();
}
Thats what I've done, but file test.accdb is not created. Works catch with mistake, that he cant find C:\DB\CPP\test.accdb
Can someone help? 🥺
Anonymous
#include <iostream>
using namespace std;
int main ()
{
static int N = 10;
int counter, sum, number;
cout << " Enter a Positive Integer smaller"
<< " or equal to 10 (the counter) ";
cin >> counter;
cout << endl;
sum = 0;
for(int i;i<10;i++)
{
cout << " Enter a Positive Integer " ;
cin >> number;
cout << endl;
sum = sum + number;
counter ++;
}
cout << " The sum of the digits you have entered is = " << sum << endl;
if ( ( sum % 2 ) == 0 )
cout << " " << sum << " is divisible by 2 " << endl;
else
cout << " " << sum << " is not divisible by 2 " << endl;
// note here no need of return anything
return 0;// because the return type of ' main ' is ' void '
} // end of main
Anonymous
VladV1V
Can anyone help with this?
#include <stdio.h>
#include <stdlib.h>
int main() {
int sz = 1;
scanf("%d",&sz);
int arr[sz],i;
for (i=0; i < sz ; i++) {
arr[i] = rand() % 100;
printf("%d:%d\n",i + 1,arr[i]);
}
return 0;
}
Write return functions a pointer to an element with an arbitrary index-dimensional array of 10 elements
I am quite new to C please sry if my code looks bad
Anonymous
Hi friends
Sid
Sid
H4
#include <stdio.h>
#include <string.h>
int main()
{
freopen("oout.txt", "w",stdout);
freopen("iin.txt", "r",stdin);
int a[100],b,c,i,j,n,x,k,y,z=-10000;
scanf("%d",&n);
for(k=0;k<n;k++)
{
for(i=1;i<=3;i++)
scanf("%d",&a[i]);
// for(i=1;i<=3;i++)
// printf("%d",a[i]);
x=(a[1]+a[3])-(2*a[2]);
// x=(a[1]+a[3]+1)-(2*(a[2]-1));
// printf("%d",x);
// printf("%d",(a[1]+a[3])-(2*a[2]));
if(x==0)
{
printf("%d\n",x);
}
else
{
if(x<0){
while(1){
// for(j=0;j<=1;j++)
// {
a[3]+=1;
a[2]-=1;
y=(a[1]+a[3])-(2*a[2]);
// printf("%d\n",y);
if(y>0){
y=((a[1]+a[3])-1)-(2*(a[2]+1));
printf("%d\n",y);
break;
}
}
// }
}
else{
while(1){
a[3]-=1;
a[2]+=1;
y=(a[1]+a[3])-(2*a[2]);
// printf("%d\n",y);
if(y<0){
y=((a[1]+a[3])+1)-(2*(a[2]-1));
printf("%d\n",y);
break;
}
}
}
}
}
return 0;
}
why time limit excidded in todays div 2 contest
H4
in codeforce
Sid