• Register

Recent questions tagged c

0 votes
1 answer 2 views
Problem: Hi there! I am confused in while loops and I need to write a program in which a value is taken as input from the user. If the value is less than 0, the program should increment it by 5 as long as the value remains less than 0. As the value becomes greater than or equal to 0, it should print the number of times the value has been incremented and the final value. Any help??
asked 16 hours ago Code Learner 5.5k points
0 votes
1 answer 4 views
Problem: Hi there! I have no prior experience in programming or even computer science. I have studied medicine in high school but could not get much out of it. Now, my interest in programming is increasing day-by-day, and I want to learn to program. I want to start with C++, and I want to know that how long would it take to learn C++ from beginner to advanced level?
asked 2 days ago Code Learner 5.5k points
0 votes
1 answer 7 views
Problem Hey, want to ask you about my problem regarding a file passing to a function. I was trying to create a file which will ask to user for its path then passing it as an argument to a new input/ output then passing that file as a reference to update file ... ::ifstream OutputFile (FilePath);     std::ofstream InputFile (FilePath);          ModifyFile(OutputFile, InputFile);     return 0; }
asked Jan 12 chris jordan 2.2k points
0 votes
1 answer 8 views
Problem: Hello! I just came across a programming problem in which the programmer has to write a program that counts the number of the same characters in two strings. I am puzzled about how to achieve the count of the same characters. I want help from you in finding the solution. Thanks!
asked Jan 8 Code Learner 5.5k points
0 votes
1 answer 14 views
Problem: Beginner here! I have got an assignment in which I have to write a program that finds the sum of array elements taken as input from the user. I have to define a function that calculates the sum and returns the sum. The program should print the sum on the ... logic is not so strong so I just failed to build logic. Could anyone from here help me find the solution to this task? Thanks!
asked Jan 8 Code Learner 5.5k points
0 votes
1 answer 3 views
Problem: Hi there! I am a beginner in programming, and I recently came across the concept of call by reference and call by address. To understand the concept better, I wrote the following programs: Call by address: #include <iostream> using namespace std; void ... So, I got more confused now. Could anybody here please explain the difference between call by address(pointer) and call by reference?
asked Jan 4 Code Learner 5.5k points
0 votes
1 answer 16 views
Problem: Hi there! I am a new learner. I want to know how I can find the position of an element given by the user in an array. I tried some programs but could get the logic. The element, whose position is to be found, will be taken as input from the ... has to choose any element of that array. Can anybody here help me understand the logic of the program? Example program will be a plus. Thanks!
asked Jan 2 Code Learner 5.5k points
0 votes
1 answer 15 views
Problem: Hello Programmers! I am a novice C programmer striving hard to learn as much programming as possible in minimum time. I came across an assignment in which the programmer has to write a program that prints the second largest number in an integer array. I tried writing such a program and I ... +) { if(arr[i] > largest) { largest = arr[i]; } } printf("%d", largest); return 0; } Output: 44
asked Jan 2 Code Learner 5.5k points
0 votes
1 answer 16 views
Problem: My problem is the following: I have a class Nodo, which has as an attribute an array of pointers toto its same type (as to make a tree) and then I have a child class NodoAvlthat must inherit that attribute but the pointers must point to the same type , that is, point to NodoAvl. ... = T ()): Node <T> (data) {} int altu () {return alt;} }; Is there a way to do this? Thanks in advance.
asked Jan 1 sasha 5.3k points
0 votes
1 answer 20 views
Problem: Errors: ||=== terrac, Debug ===| C:\terrac\gameObject.cpp|4|error: redefinition of `class gameObject'| C:\terrac\gameObject.h|3|error: previous definition of `class gameObject'| ||=== Build finished: 2 errors, 0 warnings ===| I can't figure out what's wrong. Help?
asked Dec 27, 2020 Mashhoodch 5.7k points
0 votes
1 answer 6 views
Problem: For example, if data in an external text file is like this: 45.78 67.90 87 34.89 346 0.98 How can I read this text file and assign each number to a variable in c++? Using ifstream, I am able to open the text file and assign first number to a variable, but I don't know how to read the next number after the spaces.
asked Dec 27, 2020 Mashhoodch 5.7k points
0 votes
1 answer 6 views
Problem: I just downloaded VS 2013 Community Edition and I wrote my first app. When I run it it shows in the output section: 'ConsoleApplication1.exe' (Win32): Loaded 'C:\Users\Toshiba\Documents\Visual Studio 2013\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe'. Symbols loaded ... problem? I checked my code on many sites so I know that the problem is not in my code. Can anyone help me?
asked Dec 27, 2020 Mashhoodch 5.7k points
0 votes
1 answer 10 views
Problem: How do I find the index of nth occurrence of the given string in a line? I need this to take a substring from that index. Is that possible through any functions in c++?
asked Dec 27, 2020 Mashhoodch 5.7k points
0 votes
1 answer 6 views
Problem: I get the error invalid conversion from 'const char*' to 'char*'. initializing argument 3 of 'void Printfunc(int, char*, char*)'on argument 3 of the function on the above line. The function is called as shown below void Printfunc(int a, char *loc, char *stream) please let me know if I need to change any initialization.
asked Dec 27, 2020 Mashhoodch 5.7k points
0 votes
1 answer 12 views
Problem: What does this error in Valgrind mean? I've looked at a lot of other posts but I still don't understand what the error actually means. Is there a problem with my Dragon destructor function? ==48500== Invalid read of size 8 ==48500== at 0x40AF66: Dragon::~Dragon() (in ... () (in /u3/nsah/cs246/1149/a5/cc3k/cc3k/test) ==48500== by 0x401EE1: main (in /u3/nsah/cs246/1149/a5/cc3k/cc3k/test)
asked Dec 26, 2020 Mashhoodch 5.7k points
0 votes
1 answer 8 views
Problem: I have the following error in my Calculator code and do not understand how to correct it. Please any advice would be helpful. ERROR: error: jump to case label [-fpermissive]| error:crosses initialization of 'int sum'| error: 'exit' was not declared in this scope|
asked Dec 26, 2020 Mashhoodch 5.7k points
0 votes
1 answer 45 views
Problem: I have't coded in c++ for some time and I got stuck when I tried to compile this simple snippet: class A { public: void f() {} }; int main() { { A a; a.f(); // works fine } { A *a = new A(); a.f(); // this doesn't } }
asked Dec 26, 2020 Mashhoodch 5.7k points
0 votes
1 answer 9 views
Problem: Why am I getting lvalue required as left operand of assignment with a single string comparison? How can I fix this in C? if (strcmp("hello", "hello") = 0)
asked Dec 26, 2020 Mashhoodch 5.7k points
0 votes
1 answer 11 views
Problem: I want to read csv file by using c++ so here is my code int main(){ ifstream classFile("class.csv"); vector<string> classData; while (getline(classFile, line,',')) // there is input overload classfile { classData.push_back(line); } } here is my question ... +/ Library / John is there anyway that I can separate my last column from first of next row? Thank you and sorry that it is confusing
asked Dec 26, 2020 Mashhoodch 5.7k points
0 votes
1 answer 8 views
Problem: How do you find the length of a string? How do you find the length of a string without using strlen in C++? What is size of string in C++? Find length of string without using any library or built-in function like strlen() using strlen() function using Pointer
asked Dec 26, 2020 Mashhoodch 5.7k points