I only know this from experience - when I was working on a large file and allocating memory I received a segmentation fault because I ran out of memory.
I am only a beginner with C (started last week) but this is the problem I had when working with large files.
#include <stdio.h>
int main( int argc, char *argv[] ) {
if( argc == 0 ) {
puts( "No command line available." );
} else {
printf( "The program now running: %s\n", argv[0]);
if ( argc == 1 ) {
puts( "No arguements received on the command line." );
} else {
puts( "The command...
>> or will I have to modify the code to get it to work?
>Visual studio will compile C just fine so long as you name >your source files with the .c extension.
>Or use these flags
>/Tc<source file> compile file as .c
>/Tp<source file> compile file as .cpp
>/TC compile all files as .c
>/TP compile...
Thanks for the confirmation on the error.
I do not feel ready yet to move on to C++ as I am still learning C.
I thought I could compile C code in C++ and that C++ was just C with more libraries.
I have a C compiler now for windows so I can write code for both Linux and Windows.
Thanks for...
http://www.cs.virginia.edu/~lcc-win32/
This is a free c compiler for windows. The original program went through without a error.
Thanks for the heads up on the compiler issue. I thought C++ was 'backwards compatible' to C *smiles*
When I transferred the code to the laptop and got the error I modified it completely to try and get it to work.
If I remember correctly the error was something to do with void* to person* conversion.
I was also curious to know if C code compiles under C++. I have a copy of Visual Studio 6 with...
I am wondering why this code caused an error in C++ compiler under Windows when it compiles fine under Linux with GCC.
typedef struct {int key; int digit; char string[24];}person;
person *txPtr;
if( (txPtr = calloc( store, sizeof(person) )) == NULL) {
printf("txPtr:Insufficient memory\n")...
Hey, I cant express how happy that code example has made me.
Now I have a working example of fputs and fputc that actually does what it is supposed to do *big smiles*
See, I am trying to create a list of all the unique numbers within a range - its a long story - but when I tried to do it in...
*smiles* @ over use of 8
Thanks for the info. It helps a little bit.
In fact, it was just now when I kinda figured it out. Using fgetc and fputc I was trying to input a whole string "12345678" (hence the 8's in code)
But like, I realised I am only inputting one char. When it came to reading...
Gosh, this sounds so easy! But, I am having serious problems.
I wrote a file using fwrite to record 9 number sequences of 8 digits each in length. No seperators, just a long line of digits went into the file.
Now, I want to pull a single digit from the file using fread but it really wont let...
No worries, I figured it out.
The problem was with the fread() function.
Basically, I was asking it to read 8 times the data inside the array 'a'.
So, like,
instead of;
readcount = fread( a, sizeof( a ), 8, fp);
I used;
readcount = fread( a, sizeof( a ), 1, fp);
And this extracted all the...
Basically, I am learning C under Linux. What I am attempting is fwrite and fread functions on a file.
The write program works without fault, but when I try and read the data back from the file, the data is displayed, but then at the end of it all it states 'Segmentation fault'.
So, here is the...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.