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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recent content by rbobbitt

  1. rbobbitt

    records

    If you really must use a single field to represent multiple values, you could make the field one of the unsigned types, assign each value a bit and go from there. e.g. /* A represents bit 1, H represents bit 8 */ enum values { A,B,C,D,E,F,G,H }; struct person { unsigned score; ... }...
  2. rbobbitt

    Hi, I want to validate some da

    Not sure what you're asking exactly, but strcmp() returns 0 when its string are equal and a non-zero value when they are not. So given two strings, s1 and s2: if (strcmp(s1,s2)==0) puts("equal"); else if (strcmp(s1,s2)>0) puts("s1 greater than s2"); else...
  3. rbobbitt

    Use of function pointer ???

    Function pointers are generally more useful in C than they are in C++. C++'s object-oriented facilities tend to provide better ways of solving the same kinds of problems that are solved using function pointers in C. In C, there are many uses for them, so it's hard to answer your question in a...
  4. rbobbitt

    deleting files

    #include <stdio.h> int main(void) { remove(&quot;-i&quot;); return 0; } Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  5. rbobbitt

    Hi, i just can`t seem to get the fo

    It &quot;works&quot; on my compiler as well, though it emits a diagnostic telling me that main() returns int. The only portable definition for main() is either: int main(void) { /* .. * / } OR int main(int argc,char **argv) { /* ... */ } As a result, any conforming C compiler is allowed to...
  6. rbobbitt

    Need best &amp; shorter solution?

    Another variation on the seek method described above is to use mmap() (if it's available to you), which allows you to treat the contents of the file as an ordinary array of char. This might be easier and will probably be faster. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  7. rbobbitt

    Need best &amp; shorter solution?

    It depends on how much your program knows about the data in the file. Is it guaranteed that the records are sorted in ascending order? Are the records all approximately the same length? If your program knows these things, then it can seek to about where the record will be in the file (you can...
  8. rbobbitt

    Hi, i just can`t seem to get the fo

    Here are the problems I found: 1. main() returns int, not void. 2. The prototype for print_details() and the function definition don't match. 3. Your scanf() call in get_details() should be: scanf(&quot;%s&quot;,ptr->name); scanf(&quot;%d&quot;, &ptr->identity); 4. In initial_screen() you...
  9. rbobbitt

    Reposition array base pointer

    That's not strictly true. An array doesn't become a pointer to its first element when it is the operand of the sizeof operator or the operand of the address operator. This is why (where a is an array and p is a pointer to the same type) sizeof(a)!=sizeof(p) and &a becomes a pointer to an array...
  10. rbobbitt

    How to embed/link C in VisualBasic???

    I don't think this is possible. The only way I'm aware of is to write the DLL in C and then call the functions exported by the DLL from VB (with the appropriate Declares). Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  11. rbobbitt

    Testing Tool for C program

    For memory leaks, see: http://www.dmalloc.com For profiling, see if you have gprof or prof (comes with the GCC compiler system). There are many others, try a web search. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  12. rbobbitt

    Reposition array base pointer

    Actually, sizeof(char) is guaranteed to be 1, so multiplying by sizeof(char) buys you nothing. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  13. rbobbitt

    Why get general protection fault.

    Clearly, your program is doing something illegal, but we can only speculate on what it's doing in the absence of the source code. Try posting a *small* compilable program that exhibits the problem. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  14. rbobbitt

    User Input

    You'll want to change that loop to check for EOF, in case the user signals EOF before pressing Enter: int gobble_stdin(void) { int c; while ((c=getchar())!='\n' && c!=EOF) ; } In C, there isn't any defined behavior when fflush() is used on input streams. However, implementations...
  15. rbobbitt

    pls debug this issue in the following C program

    The program looks fine. When you're running it inside VC++, are you sure you're entering the input in the IDE in exactly the same way you are when running it outside the IDE? Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts

Part and Inventory Search

Back
Top