Beginners - February 2021 (Page 5)

type casting
 
question How can a struct be converted to a pointer when struct is 8 bytes(4 x 2) bytes and a pointer is 4 bytes? Thanks Struct node{ ...
[10 replies] Last: The (node*) part is a cast to interpret the pointer as pointing to a n... (by Ganado)
Use of same class in multiple functions
 
I have a couple classes I am using throughout various functions. However, I keep creating a new instance of the class within each function like the following ...
[3 replies] Last: Thanks Handy Andy, that is very helpful and I believe points me in the... (by michaelwilliams6511)
Int variable not updating
 
I was just messing around and reviewing some of the stuff I learned and I noticed that the variable wont update. Any tips on how to fix this? #include <iostr...
[2 replies] Last: Also here -> https://www.dreamincode.net/forums/topic/420830-int-varia... (by salem c)
Can you help me with this code
 
When i compile this code, i get that c is 40, but I dont understand why is that.. If anyone can help me it would be good.. int a,b,*pa,*pb,c,d; pa=...
[3 replies] Last: This is 'c hacking at its worst'. The result is undefined as it depend... (by seeplus)
Need Help For An Assignment, really new to c++
 
Hey Guys I was wondering if anyone in this forum can help me with this assignment. I'm new to C++ and would love to learn more about it. Here's the assignment: ...
[3 replies] Last: Hello RubixIsCubed, Hey Guys I was wondering if anyone in this forum ... (by Handy Andy)
String array won't work correctly in an if statement
 
Basically the if(array == "Hello ") will not work correctly because each time I enter the input it's always the "(He left) " so I know the first if statement w...
[10 replies] Last: @Handy Andy, thank you, it helps a lot. I was not sure about the synta... (by possum swallower)
input center and a point on a circle a million times with no correct output
 
I think I may be dumb or missing something. I have attempted way to many times to get this program to output correctly and I just can't seem to do it. This i...
[2 replies] Last: ... Oh, wow. Thank you. I can't believe I missed that. (by brookeshnook)
by bstroe
Missing element
 
2 strings of numbers : n and n-1 . The elements in the second string will be in the same order as those in the first, except for one element in the first strin...
[15 replies] Last: Thanks @seeplus @lastchance ! (by bstroe)
by bstroe
The element are not in order
 
2 strings of numbers : n and n-1 . The elements in the second string will NOT be in the same order as those in the first, but all the values in the second stri...
[8 replies] Last: In which case, consider: #include <iostream> #include <set> int ma... (by seeplus)
Array sum
 
So I have to create text file from cpp. Everything worked fine before i added functions for array sum... int main () { int n = 100, sum = 0; int a...
[4 replies] Last: It can also be done as: #include <fstream> #include <iostream> #inc... (by seeplus)
linked list insertion time complexity?
 
I am learning about linked lists, and trying to understand the time complexity behind insertion, deletion, reading and searching, and I am really confused with ...
[11 replies] Last: Another important consideration for preferring the standard library li... (by JLBorges)
Help me to understand constructors and destructors
 
Here is code that I'm trying to understand #include <iostream> using namespace std; class Student; class Person { public: Person() { cout << "constructor ...
[3 replies] Last: @AbstractionAnon thank you very much, your explanation why only destru... (by d34dc0d3)
vector of queue of unique_ptr
 
Hi I understand that if you want a vector of unique_ptr then you need to use vector.push_back( move(myPtr) ) as a unique_ptr is not copyable. However, I'm stru...
[4 replies] Last: I didn't say what the problem is, so I'll do that now. vector::push_b... (by mbozzi)
Problems printing Unicode characters in Windows
 
How do I properly format the wcout statement with the L switch in my example code? As it is, it just prints out garbage to the console window. #include <...
[16 replies] Last: Yeah when i use the actual characters I get garbage. the only thing th... (by Justcus)
Implementation
 
Hello, I have to write a code and write a page to explain my implementation. But what does it mean to explain an implementation ? Thanks
[1 reply] : You're explaining the details of how your code works. Like what algori... (by Ganado)
Random number problem
 
I'm having some trouble getting random numbers for my code #include <ctime> #include <iostream> #include <cstdlib> using namespace std; int main (){ sr...
[7 replies] Last: That's exactly what I said. Anyway, he said it's fixed now, but didn't... (by dutch)
Read integers from a text file with C++ ifstream
 
So i have text file input.txt. This file consists of 54, 70, 75, 63, 17, 59, 87, 16, 93, 81, 60, 67, 90, 53, 88, 9, 61, 8, 96, 98, 12, 34, 66, 76, 38, 55, 58, 2...
[13 replies] Last: Yes, that's a good point. I didn't need special treatment for one less... (by lastchance)
Search word from file C++
 
Hi guys, I have been looking all over internet. I'm a noob with C++ so all I can find don't make sense to me and not working the way I wanted. Maybe someone he...
[19 replies] Last: Ok, I'm looking for options but it seems it's more effective the way i... (by Scorpia)
by icezy
C++ Classes and Overloaded Functions
 
I am trying to create a class name Dog with a string field for the Dog’s name. Create a class Cat with a string field for the Cat’s name. Write a program t...
[5 replies] Last: That is to what I was referring (and polymorphism) above when I mentio... (by seeplus)
Coding Challenge:
 
Why does it cout 1 ? This is the challenge: Doubled Pay An employee working at a very bizzare company, earns one penny on their first day. However, for...
[5 replies] Last: Dutch's bit shifting is just the application of the standard formula f... (by seeplus)
February 2021 Pages: 1... 34567... 12
  Archived months: [jan2021] [mar2021]

This is an archived page. To post a new message, go to the current page.