Software Development
Member Avatar

Well, this morning I tried to write a program to update environment variable's list. And I got stuck at a very crucial point. I think am making some silly mistake. …

Topic by Rahul47

Setting global environment variables are OS specific, and are essentially managed by the OS itself. The OS is responsible for passing on the default environment values to new process spaces. …

Software Development
Member Avatar

Say I have code like this...

typedef struct {
    unsigned A:1;
    unsigned B:1;
} FlagStruct;
extern FlagStruct *Flags;

Imagine that the Flags instance is a shared resource in a multi-threaded …

Software Development
Member Avatar

Say I have code like this...

typedef struct {
    unsigned A:1;
    unsigned B:1;
} FlagStruct;
extern FlagStruct *Flags;

Imagine that the Flags instance is a shared resource in a multi-threaded …

Topic by N1GHTS

I didn't make any assumptions. I was always avoiding using flags in the way I described but decided today to ask what you guys thought about it purely out of …

Software Development
Member Avatar

Say I have code like this...

typedef struct {
    unsigned A:1;
    unsigned B:1;
} FlagStruct;
extern FlagStruct *Flags;

Imagine that the Flags instance is a shared resource in a multi-threaded …

Topic by N1GHTS

Thats what I thought too which is why I've been naturally avoiding using them in that way, but it would have been so convinient and elegant if it did. Thus …

Software Development
Member Avatar

Hi,

I am just playing with C code in the console under Linux.

In the old times a fair bit of code was written for a console;
programs were operating …

Topic by zegarnek

You may be suprised how heavily used console interfaces are used in these modern times. I work with them and build them on a near daily basis in Linux for …

Software Development
Member Avatar

Say I have code like this...

typedef struct {
    unsigned A:1;
    unsigned B:1;
} FlagStruct;
extern FlagStruct *Flags;

Imagine that the Flags instance is a shared resource in a multi-threaded …

Software Development
Member Avatar

How do I show this output using for loop statement?

1
23
345
4567

Thanks in advance :)

Topic by boomboombugsh

I looked up the word "plz" in the dictionary and it does not exist, especially not one with that many letter "Z"s.

Note that the question in this thread has …

c
Software Development
Member Avatar

Hi guys, here is my code that am working on this morning, and I came across a point when pointer operation went wrong.

#include<stdio.h>

int main(){
    char a[20]="Hello World !!!"; …
Topic by Rahul47

Just a quick word of advice. It is more efficient to use fwrite() or fputc() instead of fprintf() for writing characters to a file one at a time. This is …

c
Software Development
Member Avatar

i m trying to run a mp3 file on dosbox plateform by c .i put the following code in to the batch file
start c:\xyz.mp3 and trying to call this …

Topic by vibhu mishra

Try this:

int Status = system("cmd.exe /c c:/xyz.bat");

Or on Windows 64 bit:

int Status = system("%windir%\\Sysnative\\cmd.exe /c c:/xyz.bat");

I'm not on Windows so I can't test this for you. …

Software Development
Member Avatar

i m trying to run a mp3 file on dosbox plateform by c .i put the following code in to the batch file
start c:\xyz.mp3 and trying to call this …

Topic by vibhu mishra

Note that system() returns a program status code. It is good practice to use this value for error handling.

Software Development
Member Avatar

I have two questions:
1)
Here is a small program showing how one can use Array name as Pointer variable.

#include<stdio.h>

int main(){
    int a[5]={1,2,3,4,5},i=0;
    for(i=0; i<5; i++){
        printf("\nAddress: %d\tValue: …
Topic by Rahul47

I believe Labdabeta answered the first question well. As for your second question you can technically do this...

const *p = (const *)0x05;  // Constant pointer address
char *a = …
c
Software Development
Member Avatar

Fairly easy pointer increment program is as follows.

#include<stdio.h>

int main(){
    int i,a[10],*p=a;
    for (i=0; i<10; i++,p++){
        printf("\nAddress of a[%d] is %d",i,p);
    }
    getch();
    return 0;
}

Here is output: …

Topic by Rahul47

I just tested the code and it agrees with Ancient Dragon's explanation. Sorry about that.

c
Software Development
Member Avatar

Fairly easy pointer increment program is as follows.

#include<stdio.h>

int main(){
    int i,a[10],*p=a;
    for (i=0; i<10; i++,p++){
        printf("\nAddress of a[%d] is %d",i,p);
    }
    getch();
    return 0;
}

Here is output: …

Topic by Rahul47

Integer has nothing to do with pointer size. The pointer is the size of the memory address as dictated by the Operating System based on the CPU's capabilities. A 32 …

c
Software Development
Member Avatar

The expected outcome dosent agree with result. Following is the code snippet.

int a,c;
a=10; c=0;
c=(--a)+(--a);
printf("C: %d", c);
printf("\nValue of a: %d", a);

I expected C to be …

Topic by Rahul47

Its funny to think that c=(--a)+(--a); is not any more efficient than --a;--a;c=a+a; in terms of how it compiles. Its just that the first version is ambiguous in design as …

Software Development
Member Avatar

**

import a data table with space?

**

Good day!
I need to read in all the data in a file within column two and export it in …

Topic by shakin

I'd start over from scratch with this strategy:

  1. Load the entire file into an array of strings. Create a new line for every newline character found. Don't bother with …
Software Development
Member Avatar

I'm buidling my own shell and I was trying to implement a history function, but was a little lost on where to start. I know i would like to use …

Topic by shaneetra.graham

I'm curious if your shell is merely echoing commands to another shell. What does this shell do with the commands it receives? Are they translated into a system API or …

c
Software Development
Member Avatar

I have text file in D drive named "data.txt". It have several columns and rows like
A B A B V B
B V A B A A
B B …

Topic by symon_1

These instructions assume you want to read it to memory and that the letters are being converted into numbers of equal size (1 byte):

  1. Open the file for reading …
c
Software Development
Member Avatar

I am using the gcc compiler and I am new to using flags.
Can any one tell me a source for it.
e.g. I wanted to use -funroll-loops but I …

Topic by H_beginner

This is a great resource: http://gcc.gnu.org/onlinedocs/

Software Development
Member Avatar

I just started programming in C our first asssignment is writing an alogrithm to compute the volume of water in cubic feet, flowing through a pipe of diameter d in …

Topic by kristina.densmore

Pseudo code, Flow charts, etc are nothing more than a human legible medium to stage the logic so that it can then be translated into code.

For instance you can …

c
Software Development
Member Avatar

Hi. I just got a problem running my graphics program written using C language in DOS Box. There may seem a problem using the graphics.h running through DOSBox in Windows …

Topic by Van_1

I will disagree with Acient Dragon on this one. DOSBox runs native DOS games pretty well, so you have to ask youself "what am I doing differently than these other …

Software Development
Member Avatar

Is this a "typedef" problem?
This is the definition in one file.

typedef BYTE SOCKET;   //Socket descriptor

BYTE is defined elsewhere as type char.
(I made sure the file where …

Topic by kent.johnstone_1

I would classify your question a platform specific issue since again the definition of SOCKET is not your responsability. As the programmer of the PIC32 and user of your compiler …

Software Development
Member Avatar

Is this a "typedef" problem?
This is the definition in one file.

typedef BYTE SOCKET;   //Socket descriptor

BYTE is defined elsewhere as type char.
(I made sure the file where …

Topic by kent.johnstone_1

This is illegal unless you are working on an embedded system or a very low tech system that only works with 1 byte addresses:

typedef BYTE SOCKET;

And unless you …