Not sure how to just submit Source code

I'm in a programming class at my university, and in my recent assignment my teacher asked us to submit our assignment as a source code. To my understanding a compiler takes a source code (.cpp file) and writes it as an executable file (the object code) my teacher told me I had submitted the object code, however. How exactly am I to make sure that my source code gets submitted, and not my executable file? Is the .cpp not necessarily the source file?

Also, she said I didn't have proper descriptions/comments, is there a formal way of writing those in a c++ file?

Thanks for the help in advance!
The object code is an intermediary representation the compiler generates for each translation unit before linking the final executable. Typical extensions are .o and .obj.
The .cpp is just source code, but you probably also submitted some compiler output. Maybe you use wildcards such as "my_program.*" instead of, say, "my_program.c*" when selecting/copying the files?

Also, she said I didn't have proper descriptions/comments, is there a formal way of writing those in a c++ file?
There is, in the sense that whether something is a comment or not has a format formal definition.
There isn't, in the sense that there are no formal rules for writing comments (otherwise, they'd probably be indistinguishable from actual code). There are only general guidelines, such as "comment interfaces", "warn about possible bugs/gotchas", or "comment what you think the code is doing or what it should be doing, not what it actually does" (that last one is a double-edged weapon, by the way).

Honestly, though, I don't know why teachers bother insisting that students comment code. Badly commented code is much worse than uncommented code, and you can only comment properly once you've become proficient in the language and can decide whether something needs explanation or not, and how to explain it.
Last edited on
my teacher asked us to submit our assignment as a source code.

The source code distribution depend on the project itself, for example i have i program called 'mazd' it has these file;
>main.cpp
>main.h
>sub.cpp
>sub.h


for me above is my source code.May be your teacher need something like that not, these for my example
>mazd.exe and mazd.obj
which compiler generate.
Everything you actually write is 'source code'. That is what she wants to see. She wants to see what you wrote, not what the compiler made.
@Galik
Readme file is a source code?
If you wrote it as part of the project then it would come under 'source documentation' rather than 'source code'. Source code is everything you give to the compiler.
Icons and other embedded binary files are source code?
@L B and mazd
You know what Galik means, no need to be nit picky. (unless you're writing an icon, then let me know)
closed account (Lv0f92yv)
.cpp, .C, .c, .cc, .c++, .h are all source code extensions. If you have these and they are something you made for your program, they will likely want those.

.o = object code
.exe/.bin = executable (binary) files
.something else = probably something your IDE left there when you created the project that houses project config/setting information. No need to submit this.

Topic archived. No new replies allowed.