scanf was the problem, thank you. Using fgets is now getting the whole line.
Type: Posts; User: groberts1980
scanf was the problem, thank you. Using fgets is now getting the whole line.
I've searched the forums, and implemented a lot of answers found here, but none of them seem to work entirely.
Here is the code in question:
#include <stdio.h>
#include <strings.h>...
I emailed him, this was his response:
"The page size needs to be hardcoded. I'll explain why in lecture next time. For now, just write a 2-line program to print the value and plug that value...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char ** argv)
{
int getpagesize(void);
int columns;
columns = getpagesize();
Here is the revelent part of the assignment. This was copied and pasted directly from a PDF file that we were given. I don't know what else to say. This is what the professor gave us. Keep in mind...
Can I not just declare the array as global? Can we not just talk about the syntax to do that? Its a simple question. I'm not using malloc(), nor am I storing the array in a file. Saying the professor...
Okay, I typed that into my program. Doesn't seem to help :-)
I'm afraid I do need to store it all at once. The program is for an Operating Systems course, and the current subject matter is virtual memory. We are supposed to create this 2D array, set each value...
I need to use a 2D array of chars. The first field (rows) is set at 20480. The second field (columns) needs to be set at runtime (4096 being one possible value). The size of the 2D array will be too...
So, it will compile. And it will run. With unintended consequences, but it'll run. How is that "not allowed"? C does not do boundry checking. Technically, you CAN do that. You can read and write a[...
How is new more dummy resistant than malloc? I realize my example has nothing to do with malloc/new, I just meant "safety" in terms of shooting yourself in the foot. And my example shows that you can...
I guess in the sense that this is legal in C:
main() {
int a[5];
*( a + 7 ) = 1;
a[ 9 ] = 5;
}
How would you compare C’s malloc and free functions with C++’s new and delete operators in terms of safety?