Open main menu

CDOT Wiki β

Changes

C/C++ FAQ

1,111 bytes added, 22:56, 24 September 2013
C/C++ FAQ
(header) and implementation (making a cpp file) for that class template there are
numerous compile errors. What do all these errors mean?
Q: Can Stacks, Queues or Lists be referenced using indexes? Q: How to get size of an array without storing the size anywhere? Q: How do you get the length of a file / read the entire file without explicitly knowing its length, and how do you use that data afterwards?Q: How do you compile the happy face on matrix? What is correct way to use CIO library in matrix?</pre> 
'''Q:''' Why is the postfix increment/decrement operator (e.g. a++ and a--) evaluated differently on different compilers?<br>
'''A:''' The evaluation of expressions, especially arithmetic expressions are based on sequence points which are undefined by the language. Arithmetic expressions containing complex postfix calculations are evaluated differently across different compilers because each compiler is unequally efficient. That is to say, these expressions are not portable as each compiler uses a different way to evaluate the expression based on its efficiency implementation. This can be noted by observing the process time of an expression across different platforms, which will be different for the same expression, due to different methods of evaluation. <br>
</source>
For any of these methods, to be able to work with the data afterwords simply use a common delimiter when originally generating the file, and then you can use methods like [http://www.cplusplus.com/reference/clibrary/cstring/strtok/ strtok] (for char array), [http://www.cplusplus.com/reference/string/string/find/ .find] combined with [http://www.cplusplus.com/reference/string/string/substr/ .substr] (string class) or use it as a vector (if that's required).<br>Submitted by Team42.<br><br>
 
Q: How do you compile the happy face on matrix? What is correct way to use CIO library in matrix?
Details of problem/question: The CIO library files (console.h, console.cpp, keys.h) and Happyface.cpp were transferred to Documents\A_1 folder on zenit. And when attempt was made to compile happyface.cpp, the lots of errors were generated that stated
"undefined reference to 'cio::console' or
"undefined reference to 'cio::console::(some function)'.
You can find the happyface.cpp at https://scs.senecac.on.ca/~btp300/pages/content/names.html (just scroll to the bottom)
This just happens only on zenit. The program works ok on visual studio. [Asked by Soban Akbar]
 
A: In order to compile the happyface.cpp on linux, you have to use "g++ console.cpp happyface.cpp -lncurses". [Answered by Soban Akbar]