Search Results

Search found 51 results on 3 pages for 'robuk'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • Rule of presidence == over =

    - by robUK
    Hello, I am just wondering would it be better to do this: if((fd = (open(filename, O_RDWR)) == -1)) { fprintf(stderr, "open [ %s ]\n", strerror(errno)); return 1; } or this fd = open(filename, O_RDWR); if((fd == -1) { fprintf(stderr, "open [ %s ]\n", strerror(errno)); return 1; } Many thanks for any suggestions,

    Read the article

  • difference fixed width strings and zero-terminated strings

    - by robUK
    Hello, gcc 4.4.4 c89 I got into a recent discussion about "fixed width strings" and "zero terminated strings". When I think about this. They seem to be the same thing. A string with a terminating null. i.e. char *name = "Joe bloggs"; Is a fixed width string that cannot be changed. And also has a terminating null. Also in the discussion I was told that strncpy should never been used on 'zero terminated strings'. Many thanks for any susgestions,

    Read the article

  • selecting a colour theme in the .emacs configuration

    - by robUK
    Hello, GNU Emacs 23.1.1 Fedora 13 I can select the colour theme by M-x color-theme-select I scroll down and select the clarity and beauty This works ok. However, in my configuration I am not sure how to select this. This is what I have, but doesn't work. (require 'color-theme) (color-theme-ClarityandBeauty) many thanks for any suggestions,

    Read the article

  • null terminating a string

    - by robUK
    Hello, gcc 4.4.4 c89 just wondering what is the standard way to null terminate a string. i.e. However, when I use the NULL I get the warning message. *dest++ = 0; *dest++ = '\0'; *dest++ = NULL; /* Warning: Assignment takes integer from pointer without a cast */ source code I am using: size_t s_strscpy(char *dest, const char *src, const size_t len) { /* Copy the contents from src to dest */ size_t i = 0; for(i = 0; i < len; i++) *dest++ = *src++; /* Null terminate dest */ *dest++ = 0; return i; } Just another quick question. I deliberately commented out the line that null terminates. However, it still correctly printed out the contents of the dest. The caller of this function would send the length of the string by either included the NULL or not. i.e. strlen(src) + 1 or stlen(src). size_t s_strscpy(char *dest, const char *src, const size_t len) { /* Copy the contents from src to dest */ size_t i = 0; /* Don't copy the null terminator */ for(i = 0; i < len - 1; i++) *dest++ = *src++; /* Don't add the Null terminator */ /* *dest++ = 0; */ return i; } Many thanks for any advice,

    Read the article

  • display full path of file in status bar

    - by robUK
    Hello GNU Emacs 23.1.1 I am wondering is there a way to display the path of the file in the status bar, instead of just the filename. I have to open many files in many directories, and sometimes I forget what directory they are in. Just easier to display the some of the path in the status bar if that is possible. Sometimes my directory paths are very long. for example /projects/clientserver/trunk/src/client/client.c like this in the status bar, just display the last two directories. /src/client/client.c Many thanks for any suggestions,

    Read the article

  • stack dump accessing malloc char array

    - by robUK
    Hello, gcc 4.4.3 c89 I have the following source code. And getting a stack dump on the printf. char **devices; devices = malloc(10 * sizeof(char*)); strcpy(devices[0], "smxxxx1"); printf("[ %s ]\n", devices[0]); /* Stack dump trying to print */ I am thinking that this should create an char array like this. devices[0] devices[1] devices[2] devices[4] etc And each element I can store my strings. Many thanks for any suggestions,

    Read the article

  • After mounting using sshfs I cannot commit my changes using subversion

    - by robUK
    Hello, local machine: Fedora 13 Subversion: 1.6.9 remote machine: CentSO 5.3 subversion 1.4.2 I have a project which is on the remote machine: [email protected]:projects/ssd1 I have mounted this on my local machine: sshfs [email protected]:projects/ssd1 /home/jbloggs/projects/mnt/ssd1 Everything mounts ok. So I open my project using GNU Emacs 23.2.1. When I want to comment my changes in emacs I get the following error: can't move /home/jbloggs/projects/mnt/ssd1/.svn/tmp/entries to /home/jbloggs/mnt/ssd1/.svn/entries: Operation not permitted Does anyone know of any way I can resolve this issue? many thanks for any advice,

    Read the article

  • save and compile automatically

    - by robUK
    Hello GNU 23.1.1 By clicking the F5 button I can compile my project. However, I want to extend this so that any unsaved work would be saved and then compiled. Normally I just do C-x-s to save then click F5. But can I add a line that will save without having to ask me do I want to save then it will compile, all done automatically? ; Compile program using <F5> ; Save all unsaved files here, then compile (global-set-key [f5] 'compile) Hope you understand me? Many thanks for any advice,

    Read the article

  • const ready only local copies

    - by robUK
    Hello gcc 4.4.4 c89 I am just wondering is it worth passing a const into a function. i.e. void do_something(const char *dest, const int size) The size is a ready-only so I don't want to change it. However, some developers never have this as const has it is a local copy that is being used. The pointer is const as you can change the value in the calling routine. I always have a const on ready-only local copies, as it confirms to anyone reading my code that it is a ready-only variable. And also, when coding I don't make the mistake of changing it without realizing. Many thanks for any suggestions,

    Read the article

  • useless class storage specifier in empty declaration

    - by robUK
    Hello, gcc 4.4.1 c89 I have the following code and I get a warning: unless class storage specifier in empty declaration static enum states { ACTIVE, RUNNING, STOPPED, IDLE } However, if i remove the static keyword I don't get that warning. I am compiling with the following flags: -Wall -Wextra Many thanks for any suggestions,

    Read the article

  • Display path of file in status bar

    - by robUK
    Hello GNU Emacs 23.1.1 I am wondering is there a way to display the path of the file in the status bar, instead of just the filename. I have to open many files in many directories, and sometimes I forget what directory they are in. Just easier to display the some of the path in the status bar if that is possible. Sometimes my directory paths are very long. for example /projects/clientserver/trunk/src/client/client.c like this in the status bar, just display the last two directories. /src/client/client.c Many thanks for any suggestions,

    Read the article

  • Strange problem installing a setup that I have just created.

    - by robUK
    Hello, I have both VS 2005 and 2008 installed. Just today I created a setup project in 2005 and I got this error when I tried to installed it. "The folder path 'http://sharingcentre.info' contains an invalid character." So I decided to create a simple project and added a new setup in 2005 and got the same problem. I then converted the project to 2008 and added another new setup. The same problem happened again. However, a previous setup project I created before work ok. I can install my application. Its only from today I cannot install any of my new setup projects. Using either 2005 and 2008. Has anyone else had this same problem. Searching google doesn't give me any real responses, I give the error message is too vague. many thanks for any suggestions,

    Read the article

  • Using the read function to read in a file.

    - by robUK
    Hello, gcc 4.4.1 I am using the read function to read in a wave file. However, when it gets to the read function. Execution seems to stop and freezes. I am wondering if I am doing anything wrong with this. The file size test-short.wave is: 514K. What I am aiming for is to read the file into the memory buffer chunks at a time. Currently I just testing this. Many thanks for any suggestions, #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <fcntl.h> #include <string.h> #include <unistd.h> int main(void) { char buff = malloc(10240); int32_t fd = 0; int32_t bytes_read = 0; char *filename = "test-short.wav"; /* open wave file */ if((fd = (open(filename, O_RDWR)) == -1)) { fprintf(stderr, "open [ %s ]\n", strerror(errno)); return 1; } printf("Opened file [ %s ]\n", filename); printf("sizeof(buff) [ %d ]\n", sizeof(buff)); printf("strlen(buff) [ %d ]\n", strlen(buff)); bytes_read = read(fd, buff, sizeof(buff)); printf("Bytes read [ %d ]\n", bytes_read); return 0; }

    Read the article

  • callback pattern

    - by robUK
    Hello, gcc 4.4.3 c89 I am creating a client server application and I will need to implement some callback functions. However, I am not too experienced in callbacks. And I am wondering if anyone knowns some good reference material to follow when designing callbacks. Is there any design patterns that are used for c. I did look at some patterns but there where all c++. Many thanks for any suggestions,

    Read the article

  • Logging to screen and to a file

    - by robUK
    What design pattern might apply to logging? What is normally used in this type of situation? Any good tutorials? I am writing a client-server application using C89 and gcc 4.4.4. I now need to implement some logging feature that will display log messages on the screen as well as log to a file. However, I don't want to display all log messages (warning, error, critical, unrecoverable, debug, etc). Maybe I can set so that it will display just errors and nothing else. For example, the user might not be interested in the debug messages on the screen output.

    Read the article

  • zeroing out memory

    - by robUK
    Hello, gcc 4.4.4 c89 I am just wondering what most c programmers do when they want to zero out memory. For example I have a buffer of 1024 bytes. Sometimes I do this: char buffer[1024] = {0}; Which will zero all bytes. However, should I declare like this and use memset? char buffer[1024]; . . memset(buffer, 0, sizeof(buffer); Is there any real reason you have to zero the memory? What is the worst that can happen by not doing it? Many thanks for any suggestions,

    Read the article

  • Why use Visual Studio 6 for C++

    - by robUK
    Hello, I am just wondering why programmers who program in C++ for windows always use Visual Studio 6 instead of Visual Studio 2008? Isn't the compiler in 2008 much better than the one in VS6? The reason I ask as I have used many sdk's that are always written in VS6? Many thanks, Steve

    Read the article

  • Finding where varables have been declared in what file?

    - by robUK
    Hello, GNU Emacs 23.1.1 I am maintaining someones code. There are many files and directories for the headers and source files. I am wondering if there is a easy way to use emacs that when I highlight a variable name I can go straight to where it is declared? Some of the structures I am working in are declared in other header files, rather than go searching for them, I just want to be taken straight to them. Many thanks for any suggestions,

    Read the article

  • Getting the callers of a specific function

    - by robUK
    Hello, GNU Emacs 23.1.1 I am just wondering is there any feature in emacs where I can find out what functions call a specific function. In my code, I normally have to do a search on the function name to see what functions calls it. It would be nice if I could display all the names of the functions where this specific function is being called from. many thanks for any suggestions,

    Read the article

  • create logging so that the messages will be displayed on screen and logged to a file

    - by robUK
    Hello, gcc 4.4.4 c89 I am writing a client/server application. I have finished and now I want to implement some logging feature that will display log messages on the screen as well as log to a file. However, I don't want to display all log messages (warning, error, critical, unrecoverable, debug, etc). Maybe I can set so that it will display, just errors and debug messages and nothing else. For example, the user might not be interested in the debug messages. Is there any design-pattern that I can follow? What do you normally for for logging? Any tutorials out there that address logging? many thanks for any suggestions,

    Read the article

  • closing sockets on linux and windows

    - by robUK
    Hello, gcc 4.4.4 c89 Visual Studio VC++ 2008 I am writing a cross platform client server application. It will run on both linux and windows. However, I am just wondering what I have done for closing the sockets is correct. I close the file descriptor. However, if there is a problem with closing it. What is the best way to handle this. Maybe some data is still being sent or received? Many thanks for any advice, if(close(sockfd) == -1) { #if defined ( _WIN32 ) fprintf(stderr, "[ %d ] [ %s ] [ %s ] [ %d ]\n", WSAGetLastError(), strerror(errno), __func__, __LINE__); #elif( __linux__ ) fprintf(stderr, "[ %s ] [ %s ] [ %d ]\n", strerror(errno), __func__, __LINE__); #endif return CS_FAILURE; }

    Read the article

  • Using sizeof with a dynamically allocated array

    - by robUK
    Hello, gcc 4.4.1 c89 I have the following code snippet: #include <stdlib.h> #include <stdio.h> char *buffer = malloc(10240); /* Check for memory error */ if(!buffer) { fprintf(stderr, "Memory error\n"); return 1; } printf("sizeof(buffer) [ %d ]\n", sizeof(buffer)); However, the sizeof(buffer) always prints 4. I know that a char* is only 4 bytes. However, I have allocated the memory for 10kb. So shouldn't the size be 10240? I am wondering am I thinking right here? Many thanks for any suggestions,

    Read the article

  • Initializing an array after declaration

    - by robUK
    Hello, gcc 4.4.3 c89 I have the following code as a sample of what I am trying to do. I don't know the actual size of the array, until I enter the function. However, I don't think I can set the array size after I have declared it. I need it global as some other functions will need to access the device names. Many thanks for any suggestions, /* global */ char *devices_names[]; void fill_devices(size_t num_devices) { devices_names[num_devices]; /* start filling */ }

    Read the article

  • Initializing a array after declaration

    - by robUK
    Hello, gcc 4.4.3 c89 I have the following code as a sample of what I am trying to do. I don't know the actual size of the array, until I enter the function. However, I don't think I can set the array size after I have declared it. I need it global as some other functions will need to access the device names. Many thanks for any suggestions, /* global */ char *devices_names[]; void fill_devices(size_t num_devices) { devices_names[num_devices]; /* start filling */ }

    Read the article

  • Rule of precedence == over =

    - by robUK
    Hello, I am just wondering would it be better to do this: if((fd = open(filename, O_RDWR)) == -1) { fprintf(stderr, "open [ %s ]\n", strerror(errno)); return 1; } or this fd = open(filename, O_RDWR); if(fd == -1) { fprintf(stderr, "open [ %s ]\n", strerror(errno)); return 1; } Many thanks for any suggestions,

    Read the article

< Previous Page | 1 2 3  | Next Page >