the best for everyone
#include <stdio.h> typedef struct { int roll ; char name[20]; double gp; }Student ; void inputStudent(Student *studentPointer){ printf("Enter a number of a roll"); scanf("%d",&studentPointer->roll); printf("Enter a name of the student"); // scanf("%[^/n]s",&studentPointer->name); fgets(studentPointer->name,20,stdin); // pay attention at this printf("Enter a grade of the student"); scanf("%lf",&studentPointer->gp); } void printStudent(Student student){ printf("roll = %d , name = %-20s , grade = %10,2lf \n",student.roll,student.name,student.gp); } int main(){ Student s ; inputStudent(&s); printStudent(s); return 0; }
Max
yep address was from SDK funktions of game. What i need to do if i want to get another address of like this but not from UWorld, from another class. What I need to focus to get the address I want?
Max
Bro can u show me, how to import my function if i send u full of the code in zip file. Im stucking with this problem for a week.
Max
No I just need how to import the function?
Anonymous
No I just need how to import the function?
Just open the zip file with winrar
Max
This items to find class or what?
D
it really isnt hard to google lol
It's high, also that article is from 2020, when it was considered as low level
Артем
Breaking
hello everyone hope you are all right , can you suggest me some idea project for C/C++ langage ??? any idea all welcomed
Ольга
I'm sorry I have a question typedef it is C or C++?Because I need only C
Ольга
i think it is C
I think that is right. Hope it really is. Thenks
Pavel
I'm sorry I have a question typedef it is C or C++?Because I need only C
typedef can be used in C or C++, but in C++ there are better alternatives (using), and in modern C++ typedef is very rarely used. Also in C++ you don't have to use typedef to declare structs.
Anonymous
why is it like this ?
I have tried it and this allows u to enter gpa
Aurora
Can cmake subprojects reference the header files of subprojects?
Anonymous
Can cmake subprojects reference the header files of subprojects?
When you say subprojects, do you mean something that you add using add_subdirectory? Sub projects could mean a lot of things like independent projects brought in using git submodule or a nested project structure with a CMakeLists.txt file with a project command or just a nested structure brought in using add_subdirectory. Which of these do you mean?
Aurora
In VS is work .Just replace PROJECT_SOURCE_DIR with CMAKE_SOURCE_DIR
Aurora
But in AS I don't know what I did wrong
Aurora
A{ project ("A") add_library(A a.cpp) target_include_directories(A PUBLIC ${PROJECT_SOURCE_DIR}) } B{ cmake_minimum_required (VERSION 3.8) project ("B") get_filename_component(A_PATH ${PROJECT_SOURCE_DIR}/../A ABSOLUTE) include_directories(${A_PATH}) message(">>>> ${A_PATH}") add_library(B b.cpp) target_include_directories(B PUBLIC ${PROJECT_SOURCE_DIR}) target_include_directories(A PUBLIC ${A_PATH}) } Main{ cmake_minimum_required (VERSION 3.8) project ("CMakeProject1") add_subdirectory(A) add_subdirectory(B) add_executable (CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h") target_link_libraries(CMakePro }
Aurora
These is in VS
Aurora
in AS Log{ cmake_minimum_required(VERSION 3.18.1) project("clog") message(${PROJECT_SOURCE_DIR}) #aux_source_directory(. DIR_SRCS) #add_executable(log_server ${DIR_SRCS}) add_library(clog Log.cpp) target_include_directories(clog PUBLIC ${PROJECT_SOURCE_DIR}) } goahead{ cmake_minimum_required(VERSION 3.18.1) project("goahead") find_package(shadowhook REQUIRED CONFIG) get_filename_component(LOG_PATH ${PROJECT_SOURCE_DIR}/log ABSOLUTE) include_directories(${LOG_PATH}) message(${LOG_PATH}) #include_directories(${PROJECT_SOURCE_DIR}/log) add_subdirectory(log) add_subdirectory(event) add_library( goahead SHARED goahead.cpp) find_library( log-lib log ) target_link_libraries( goahead shadowhook::shadowhook clog ${log-lib} ) target_include_directories(goahead PUBLIC ${LOG_PATH}) }
Aurora
So what's wrong guys
Aurora
no add_executable?
Anonymous
A{ project ("A") add_library(A a.cpp) target_include_directories(A PUBLIC ${PROJECT_SOURCE_DIR}) } B{ cmake_minimum_required (VERSION 3.8) project ("B") get_filename_component(A_PATH ${PROJECT_SOURCE_DIR}/../A ABSOLUTE) include_directories(${A_PATH}) message(">>>> ${A_PATH}") add_library(B b.cpp) target_include_directories(B PUBLIC ${PROJECT_SOURCE_DIR}) target_include_directories(A PUBLIC ${A_PATH}) } Main{ cmake_minimum_required (VERSION 3.8) project ("CMakeProject1") add_subdirectory(A) add_subdirectory(B) add_executable (CMakeProject1 "CMakeProject1.cpp" "CMakeProject1.h") target_link_libraries(CMakePro }
This is not the right way to do things even it works for you. Your projects A and B have a CMakeLists.txt file with a project command. Ideally they should be treated like dependencies and not sub projects. To include header files from dependencies, the recommended way in Modern CMake is to create an imported target with transitive dependencies that get passed on to targets that depend on them. So your A and B projects can set target_include_directories with either PUBLIC or INTERFACE property depending on whether they themselves use that include directory or whether they just want downstream targets to use that include directory. Now main can use target_link_libraries to add a dependency to this imported target and automatically bring in the include_directories dependency.
Aurora
Ok let me try
Aurora
Bro. I need B sub include include A header
Anonymous
Bro. I need B sub include include A header
Well set up an INTERFACE library in A sub that sets target_include_directories to the include headers path in A. Make this interface library a dependency for B Sub. What is stopping you from doing this? But to be honest, I still don't have a clear picture of your dependency graph. If you make your dependency graph look like sphagetti, you are going to have trouble later on when your code grows. Check to see if B Sub needs to have a dependency on A Sub or if you can remove the common parts into something like a utils library which A Sub and B Sub can both depend on rather than B Sub depending on A Sub.
Nana
I have these lines of code. I'm tryna build a POS System. Pls how I do I remove an item from the list or add additional item before the total price is printed
klimi
It's unfortunate that the code is too long to be pasted here. Can someone help in private
#paste <- If you have read the rules, you would know this exists
the best for everyone
I have tried it and this allows u to enter gpa
did it work with you ? why didn't it work with me
the best for everyone
Ludovic 'Archivist'
klimi
We should add godbolt.org to these
if you feel like it, you can do it :P
Anonymous
We should add godbolt.org to these
Added godbolt and wandbox
Pavel
Added godbolt and wandbox
Not sure about the order, I would start with the simplest one from the list, not sure if everyone can figure out how to share code from godbolt
Anonymous
Not sure about the order, I would start with the simplest one from the list, not sure if everyone can figure out how to share code from godbolt
Done. But TBH, figuring out how to use a site like GodBolt should be easier when compared to learning C/C++.
Dm
Does someone know how to add your custom library to make this line possible: #include <mylib/myheader.h> ?
Лазиз
Hello guys👋🏼👋🏼👋🏼 Please help🙏🙏🙏 Develop an src/edit.sh script for replacing substrings in text files. The input data must include the path to the file (relative to the root directory), the string to be replaced, and the replacement itself (as a string). The information on each change must be added to the log: src/files.log in the format described in the previous quest. Pay attention to the processing of edge cases.
Llll
Can anyone send me the link to the telegram channel having links to other programming groups? The one called IT something...
Llll
Pavel
Does someone know how to add your custom library to make this line possible: #include <mylib/myheader.h> ?
You can add any folder as include directory, then in tag folder add folder mylib and add headers of your "library" there. Then it depends what you want to do with it, you can compile cpp files of that "library" as a static library and link it, or just compile them together with your project. Or you can do header-only library if you use C++ and don't mind long compilation times :D
Pavel
doing or helping are two different things. I ask for help.
Can you specify what you've done then? You just posted your task and no info of what help you actually need
Pavel
I mean, if it's related to C/C++, if it's not related, then this is not the group
Divyanshi
What does it mean by runtime error (SIGSEGV)??
Pavel
What does it mean by runtime error (SIGSEGV)??
The app tried to do something that is prohibited by the OS (e.g. writing into a memory that doesn't belong to the app) https://en.m.wikipedia.org/wiki/Segmentation_fault
Pavel
What does it mean by runtime error (SIGSEGV)??
https://stackoverflow.com/questions/1564372/what-causes-a-sigsegv
Divyanshi
So what change do I need to make in my code to avoid this?
Divyanshi
int n,s; cin>>n; int ar[20]; for (int i=0;i<n;i++){        cin>>ar[i];        s=s+ar[i]; } cout<<s;
Divyanshi
This is the code
Pavel
So what change do I need to make in my code to avoid this?
I haven't seen your code, but you need to insure you never use uninitialized pointers, don't try to change constants, don't access memory after it has been deleted/freed, check your pointer math that it's correct and you don't read for example out of bounds of arrays, don't delete memory twice, and maybe some other things that I don't remember
Divyanshi
Otherwise I have written that in the code
Pavel
It can be.... Oh right i forgot to write it here
So then it's reading out of bounds of the array
Pavel
So what is the solution to this?
Depends on how you want your program to react, should it be able to process bigger amounts of elements?
Divyanshi
I think it should...
Pavel
I think it should...
Then instead of using fixed size array you can allocate it dynamically and then delete it later. Or, because you're writing in C++ you can use std::vector that will do that for you. int n; int s = 0; cin>>n; vector<int> ar; ar.reserve(n); // just to make it a bit faster for (int i=0;i<n;i++){ int value; cin>>value; arr.push_back(value); s += ar.back(); } cout<<s;
Pavel
I think it should...
However, if you just want to calculate the sum, you don't need the array
Divyanshi
However, if you just want to calculate the sum, you don't need the array
In the question it was given that we are given an array of length n
Divyanshi
new?
Pavel
new?
Yes, I guess the answer is "no" then :)
Divyanshi
Yeah lol
Divyanshi
I am sorry I am new to c++