warning: assignment makes integer from pointer without a cast
When I declare a char * to a fixed string and reuse the pointer to point to another string I tried to recast the pointer but no success.
When I declare a char * to a fixed string and reuse the pointer to point to another string I tried to recast the pointer but no success.
I’ve seen some code online and I’m trying to work out what it is doing. In particular, I’ve never seen “1e” convention before.
The ld returned 1 exit status error is the consequence of previous errors. In your example there is an earlier error – undefined reference to ‘clrscr’ – and this is the real one. The exit status error just signals that the linking step in the build process encountered some errors. Normally exit status 0 means success, and exit status > 0 means errors. … Read more
++i will increment the value of i, and then return the incremented value. i = 1; j = ++i; (i is 2, j is 2) i++ will increment the value of i, but return the original value that i held before being incremented. i = 1; j = i++; (i is 2, j is 1) For a for loop, either works. ++i seems more common, … Read more
Read Byte by Byte and check that each byte against ‘\n’ if it is not, then store it into bufferif it is ‘\n’ add ‘\0’ to buffer and then use atoi() You can read a single byte like this See read()
On Linux systems and OS X, the character to input to cause an EOF is Ctrl–D. For Windows, it’s Ctrl–Z. Depending on the operating system, this character will only work if it’s the first character on a line, i.e. the first character after an Enter. Since console input is often line-oriented, the system may also not recognize the … Read more
I don’t see any reason to prefer bzero over memset. memset is a standard C function while bzero has never been a C standard function. The rationale is probably because you can achieve exactly the same functionality using memset function. Now regarding efficiency, compilers like gcc use builtin implementations for memset which switch to a particular implementation when a constant 0 is detected. Same for glibc when builtins are disabled.
This declaration: would occupy 8 * 1000 * 1000000 bytes on a typical x86 system. This is about 7.45 GB. Chances are your system is running out of memory when trying to execute your code, which results in a segmentation fault.
You are declaring the fixed size arrays in the struct. Maybe you want to do this:
What you are doing is printing the value in the array at spot [3][3], which is invalid for a 3by3 array, you need to loop over all the spots and print them. This will print it in the following format if you want more exact formatting you’ll have to change how the printf is formatted.