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

    Logic & switch statement

    Initializing un-initialized variables before use is good practice in all instances. If you really feel the memset will give you a performance hit then you should design your code so that your variable is initialized at compile time (global) or in the declaration or use pointers. However, the...
  2. rwb1959

    Logic & switch statement

    You would use "memset" to initialize the memory allocated by the statement... char proddir[20]; ...since this is declared inside "main()", it is local in scope and allocated on the stack. These types of variables (automatic) are not initialized and it is always good...
  3. rwb1959

    Logic & switch statement

    What part of the code gave you a core dump? I assume that it may be later on (after the switch) when you are actually using "poddir". Your code may require "writable" space at "proddir" in which case char *proddir = "Food"; will point to...
  4. rwb1959

    usage of \n and \c in scripts

    try using... echo -e "Enter your name: \c" The "-e" enables interpretation of the "backslash" escape characters (i.e. "\c")
  5. rwb1959

    Logic & switch statement

    declare your variable as... char *proddir; ...the compiler is complaining about the fact that you are assigning a predefined array "proddir[20]" to a constant (which is stored on the heap). This does not copy the data it just tries to reassign the pointer to the memory allocated for...
  6. rwb1959

    Inherit permissions

    You could first create all the subdirs first... mkdir main mkdir main/sub1 mkdir main/sub1/sub2 ...then do... chmod -R 775 main ...this will do a recursive "-R" chmod starting at "main"
  7. rwb1959

    Need to update old turbo c program

    Well if you're going with new equipment, I would also go with new software. I would think that you would get some Windows GUI software with the new scales anyway. In any case, you may have difficulties building the Borland code on the new system.
  8. rwb1959

    Symbols in shareable object file

    Try: ar -w mylib.so
  9. rwb1959

    mixing char in

    If you really want the "long" mixed in... ... char buf[128]; long year = 2002L; sprinf(buf, "Hello World %ld\n", year); ...subtle difference :)
  10. rwb1959

    reading data from a socket

    Normally you would just read for the number of bytes you want then go do somthing. In your code, the only thing that will break you out is some sort of signal or error (ie. the other end disconnects you get a broken pipe) You can also set up the socketfd in a "poll" fdset and...
  11. rwb1959

    Need to update old turbo c program

    Well... it's been a long time since I've done any DOS programming but from the looks of it, I'm assuming you have a device (scale?) attached to the serial port at COM2 from the line... int portbase = 0x2f8; /* I assume you meant "=" and not "-" */ ...Again, making (lots of)...
  12. rwb1959

    help

    Here's one way... #include <stdio.h> #include <string.h> main() { float f1 = 1845.32; int r1 = 0; char *p, sf1[20]; sprintf(sf1, &quot;%6.2f&quot;, f1); /* convert float to string */ printf(&quot;SF1 = %s\n&quot;, sf1); p = strchr(sf1, '.'); /* find the decimal point...
  13. rwb1959

    4 code menu driven software system needed!

    A simple google search on &quot;C programming tutorial&quot; will turn up lost of places but you can try... http://www.mono.org/~arny/c/index.html
  14. rwb1959

    convert unix long time to get hour

    use the localtime() function. It returns a struct of type tm struct tm *localtime(const time_t *clock); The members of the tm structure are: int tm_sec; /* seconds after the minute - [0, 61] */ /* for leap seconds */ int tm_min; /* minutes after...
  15. rwb1959

    End of File/constant char

    vi recognizes &quot;\n&quot; as end-of-line. There's nothing actually wrong with the text file.
  16. rwb1959

    Malloc

    Take a look at &quot;realloc()&quot;... http://www.ajk.tele.fi/libc/stdlib/realloc.3.html
  17. rwb1959

    fread problem

    try... do { if(fread(&partrecord, sizeof(part), 1, inp) < 1) { if(feof(inp) != 0) { fclose(inp); break; } perror(&quot;fread&quot;); ... we may have been interrupted ... and may have some data in the buffer fclose(inp)...
  18. rwb1959

    Displaying Current Date in C program

    All kinds of ways (how do you think the &quot;date&quot; command works?) Anyway, you also have &quot;asctime()&quot;... SYNOPSIS #include <time.h> char *asctime(const struct tm *timeptr); DESCRIPTION The asctime() function converts the broken-down time in the structure pointed to by...
  19. rwb1959

    Reading a text file into an array

    There are at least a half a dozen ways to do this and here's one... In your program, setup a character pointer and an array buffer of some size... char *p, buf[1024]; ...then open the file for reading... fd = open(...) ...then read into the buffer... while(read(fd, (void *)buf...
  20. rwb1959

    Consulting Agreement

    Well... I don't know what your current &quot;contracts&quot; with these clients look like but in cases like this, you don't really have many options. The client may have a very heterogenious environment in which all possible &quot;side-effects&quot; just cannot be realistically accouted for. In...

Part and Inventory Search

Back
Top