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 Wanet Telecoms Ltd 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: *

  1. rbobbitt

    records

    ...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; ... }; Then, some macros for...
  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 ???

    ...sentences :-) Consider the standard function atexit() which is used to register functions to be called at program termination: int atexit (void (* function)(void)); It accepts a pointer to a function that accepts no parameters and returns void. To use it, you would define one or more...
  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

    ...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 reject any C program that does not...
  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, but it has at least one problem. Don't test for feof() at the top of your loop like that. feof() doesn't evaluate the stream it's passed. As a result, your fgets() call below it will return NULL when *it* encounters end-of-file. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  8. rbobbitt

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

    ...scanf(&quot;%s&quot;,ptr->name); scanf(&quot;%d&quot;, &ptr->identity); 4. In initial_screen() you have a statement with no effect: (&quot;\n\t*************************************************\n&quot;); 5. In main() you pass print_details() an incompatible type. Change it to this...
  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
  16. rbobbitt

    using online dictinonary in code

    How you do this depends on the format that your dictionary is stored in. First, you'll need a dictionary. Check this out: http://www.helsinki.fi/~hkantola/dict.html Also, this is the C forum. Since you plan to do this in C++, you should post to one of the C++ forums. Russ...
  17. rbobbitt

    pls debug this issue in the following C program

    Repost your code and this time uncheck &quot;Process TGML&quot;. What's happening is your indices are being treated as commands to display the text in italics. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  18. rbobbitt

    Please help me

    A few others to try: Cygwin (UNIX emulator for Win32 with GCC): http://www.cygwin.com LCC-Win32: http://www.cs.virginia.edu/~lcc-win32/ DJGPP: http://www.delorie.com/djgpp/ Borland C++ (also a C compiler): http://www.borland.com/bcppbuilder/freecompiler/ For editors: VIM (free)...
  19. rbobbitt

    Please help me!!

    You can write DLLs in C and call the exported routines from a VB program. You can't compile C programs using VB, though, as far as I know. Russ bobbitts@hotmail.com http://home.earthlink.net/~bobbitts
  20. rbobbitt

    How to Read CSV from a file

    Here's a sample (untested) #include <stdio.h> #include <string.h> #define STRIP_NEWLINE(S) do { char *tmp=strchr(S,'\n'); if (tmp) *tmp=0; } while (0) #define MAXLINE 100 /* suit to taste */ int main(void) { FILE *fp=fopen(&quot;csv.txt&quot;,&quot;r&quot;); if (!fp) {...

Part and Inventory Search

Back
Top