Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  • Users: GoAskAlice
  • Order by date
  1. GoAskAlice

    Kernighan and Richie problem

    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.
  2. GoAskAlice

    Read Input Into Array

    Sorry, argc will equal TWO if a command line parameter was passed to the program.
  3. GoAskAlice

    Read Input Into Array

    #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...
  4. GoAskAlice

    calloc error under C++ compiler (works fine with GCC)

    >> 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...
  5. GoAskAlice

    calloc error under C++ compiler (works fine with GCC)

    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...
  6. GoAskAlice

    calloc error under C++ compiler (works fine with GCC)

    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*
  7. GoAskAlice

    calloc error under C++ compiler (works fine with GCC)

    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...
  8. GoAskAlice

    calloc error under C++ compiler (works fine with GCC)

    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")...
  9. GoAskAlice

    How to pull one character from file?

    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...
  10. GoAskAlice

    How to pull one character from file?

    *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...
  11. GoAskAlice

    How to pull one character from file?

    #include <stdio.h> #include <stdlib.h> int main() { FILE *fp; char *s = "12345678"; long t = atol(s); printf("%ld\n",t); fp = fopen( "dbat", "w" ); fputc(*s,fp); fclose( fp ); fp = fopen( "dbat", "r" ); int c; int cnt = 0; char buffer[8]; while (cnt < 8) { c = fgetc( fp ); buffer[cnt++]...
  12. GoAskAlice

    How to pull one character from file?

    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...
  13. GoAskAlice

    Segmentation fault with File I/O

    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...
  14. GoAskAlice

    Segmentation fault with File I/O

    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...

Part and Inventory Search

Back
Top