general question

Hey everyone,

First of all, I find this forum extremely helpful. It's amazing how much people help and learn things. I attend school and have a C++ class. The book however, gives very basic examples. I try to ask questions so I understand my assignment more and to be honest I get stuck a lot. It's very disappointing. Some questions I can't ask because I would just have to post my code on here. Although I feel like that would help, but I don't know if that's defeating the purpose of the assignment. I guess, I would like to see everyone's view on this. I have learned a lot from this forum. Do I paste my code to show what I'm stuck on or do I ask questions that might steer me in the right direction? Thanks in advance everyone. Hope everyone stays safe.
Last edited on
if possible, try to write a little example of your question in a side program and ask about that. If you post your assignment and code, there are people who may just solve it for you, which does defeat the purpose.

If you can't do that, post the whole thing and make it clear you want a nudge not a do it for me, by asking good questions with details up front.

Also be very clear if your class prevents you from using the language tools. A lot of things are forced to be done by hand that the language can do for you, and we need to know if your hands are tied and in what ways.

Your attitude is refreshing, many just want the answer, few seek to learn :(

I feel that for the first few most basic programs, doing it for someone is just as useful as trying to explain it. Seeing the working code is often the inspiration that is needed. That kind of help is only useful for a very short time, though.
Last edited on
I appreciate the advice. Right now, we are working on arrays and pointers. While I understand what an array does as well as a pointer, I don't get how to put them into functions. For example, we have this char array that stores a line of text and the pointer goes through it letter and then you print it out. Obviously you got to take the space into account. Then I need to print the array in reverse and backwards. Count the letter in each word and stuff like that. lol. I basically do trial and error. I email my teacher a lot.lol. I might be a little hopeless.
pointers are difficult to learn for a new programmer. A lot of languages have done everything possible to eliminate the entire concept, and c++ is headed that way (minimal pointer usage is recommended and easier to do with language growth).

arrays in functions can be masked with a pointer, and that will keep what you need to know simple. look:

void foo(char* cp, int len) //note how we pass the size of arrays to functions that accept arrays.
{
for(int x = 0; x < len; x++) cout << cp[x];
}

char x[] = "hello world!";
foo(x, strlen(x)); //passed an array to a function that wants a pointer. simple way to deal with it.

but there is a very important idea around pointers and references here.
in function foo, the POINTER is named cp. cp is not a reference variable. If you say cp = new char[10]; inside the foo function, and then do cout << x down in main, x did not change, because cp the pointer variable was NOT passed by reference. Ok, now here is the thing. The data CP points to, though, is in a fixed memory location. If you change the data at that location in foo, it stays changed forever, as if by reference, even though cp itself was not passed by ref!! Both main and foo look at the same piece of memory, main calls it x, foo calls it cp, but its the same place in memory, and one byte of memory can only have 1 value at any one time. Because of this idea, arrays and pointers, the data inside them, are always 'as if' passed by reference, so be aware of this.

Some questions I can't ask because I would just have to post my code on here. Although I feel like that would help, but I don't know if that's defeating the purpose of the assignment.

IMO, it doesn't defeat the purpose of the assignment as long as you learn from the help you ask for or find. The manner of the help is secondary - whether you obtain a complete example or just hints.

While it is ultimately your responsibility to use the help you find on the internet ethically, you're not obligated to beat your head against the keyboard until your face types a working solution. Use the resources at your disposal - ask for help.

Last edited on
Topic archived. No new replies allowed.