Programming :: Declaration A Variable In One File And Initializing In Another?

Nov 25, 2010

I made 2 files which are different from the program above one is temp1.h and another is temp2.c to understand how extern is used. So here is temp1.h

Code:

#include<stdlib.h>
typedef struct node * bond;
extern int jk;

and temp2.c is

Code:

#include<stdio.h>
#include<temp1.h>
struct node {
int data;

[code]...

I had declared jk in temp1.h as an extern int so why can I not initialize it in temp2.c?

View 5 Replies


ADVERTISEMENT

Programming :: Initializing A Variable In C?

Nov 5, 2010

Following is the way I saw a variable initialized in C

Code:

static const unsigned int rtl8139_rx_config =
RxCfgRcv64K |
(RX_FIFO_THRESH << RxCfgFIFOShift) |
(RX_DMA_BURST << RxCfgDMAShift);

on following link

[URL]

I have initialized variables in past but above initialization I could not understand what is it?

View 4 Replies View Related

Programming :: C++ Multiple Variable Declaration Error - Even After I Set #ifndef Preprocessor

Jan 18, 2011

Why do I still get mutiple definition of "_my_variable" error even after I used the #ifndef preprocessor in my hpp file?

This is my scenario
I have:
1. A.cpp (including X.hpp)
2. B.cpp (including X.hpp)
3. X.hpp

[Code]...

View 4 Replies View Related

General :: Variable Declaration In Shell Scripts?

Feb 4, 2010

We have a file that declares many environmental variables. Out of which I have doubt on few. These variables are declared in UNIX environment. We are planing to migrate them along with applications to Linux.

Code:
export MAILSERVER="%new@hub"
MAIL_USERS="vinay.new"{MAILSERVER}",vijay.new"{MAILSERVER}
Does the above declarations work in Linux ?
The above declarations expands to
Code:
mail vinay.new%new@hub,vijay.new%new@hub
which looks little wierd.

[Code]...

View 4 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Programming :: QWebView, Forward Declaration, "error: Forward Declaration Of 'struct QWebView'"?

Dec 28, 2010

I am trying to include a QWebView widget in my application. Every time I try to compile it, I just get these errors:

Code:
$ LANG=en_US make
g++ -c -pipe -O2 -march=i486 -mtune=i686 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -

[code].....

View 1 Replies View Related

Programming :: Variable String File Base - Output File Doest Not Exclude The Values In Grep -av

May 1, 2011

My script.

This is may script:

Code:

Problem: Output file doest not exclude the values in grep -av

View 3 Replies View Related

Programming :: Pointer Vs Array Declaration?

Jul 26, 2010

Whats the practical diffrens between these declarations in c?

char *a_str = "hello";
char a_str[] = "hello";

View 4 Replies View Related

Programming :: Zip A Variable With PERL Without Reading Or Writing A File?

Jun 20, 2010

There is the Archive::Zip I think I can use with Perl 5.10 but I don't know how. I don't want to read or write any files, just zip something in memory, with best compression, like

$text = "this is a test";
$zippedtext = &Zip($text);
sub Zip {

[code]...

I guess it's only a few lines.

View 3 Replies View Related

Programming :: Looping Using While Read Line And A Variable Instead Of A File?

Sep 24, 2010

I created the following.

x="top
middle
bottom"

I would like to make the following work.

while read line
do
echo $line
done

instead of importing a file I would like to use the variable $x I tried using pipes, but with no luck. My goal is to read one line at a time, but not have to export my data to another file, I would like to keep it all within one script.

View 3 Replies View Related

Programming :: Make Variable To Refer A File In A Folder?

Dec 16, 2008

How can i make a variable in a bash script, to refer each file in a folder,and to switch it to the next file,until the last file of the folder?

View 2 Replies View Related

Programming :: IDE Features: Function Declaration In Info Bubbles?

Jun 3, 2009

I can't remember what it's called, but this feature of VC++ basically catalogs all the functions of a project, lets you right click on a function and go directly to it's declaration or definition, do not pass go, do not collect 200 dollars. it also gives you an info bubble of the variable types as you're typing a function's name.

this is a very convenient feature, and I'd like to use it with KDevelop, or really any full C++ IDE for linux. does such a thing exist?

View 1 Replies View Related

Programming :: Initializing A Structure To Zero?

Nov 20, 2009

I have a struct (small instance so not using code brackets )

struct random {
int a;
int b;
}example;

What i am trying is

example={0,0};

and it gives an error how to initialize all the entries within a struct to zero? In the above example i have used integers but what if they are some other data structure for example another structure?

View 2 Replies View Related

Programming :: Semaphore Used Without The Initializing?

Nov 4, 2010

I am using semaphore.h I declared a variable of type sem_t. I am able to use the variable without even calling sem_init or sem_open, and it is working properly.if the variable is automatically assigned some value? Also would I run into any trouble doing so?

View 1 Replies View Related

Programming :: Check That The Same File Exists Within Two Different Directories Using A Filename As A Variable?

Apr 30, 2010

I am in need of a way to check that the same file exists within two different directories using a filename as a variable. Here is the process which requires it: The script is reaches out (via ftp) and pulls down a file(s) and delete it afterwards. This is halfhazard because in the instance it doesnt pull down the file, yet still deletes it, we are up a creek. I am looking to pull it down to a temp location and then verify that file exists in the location in which it needs to be present to process before deleting it, adding a little extra layer for security. The script itself is finished.If I put a file name in manually it works perfect. I just need a way to pump the filename into the variable.

View 1 Replies View Related

Programming :: Bash Scripting...read A Value From A File Then Assign To Variable?

Feb 27, 2011

At my wit's end I can't find anything that I understand well enough to use. This is for a Unix class, we are working with shell scripting. File1 has 5 in it and File2 has 100 in it.The teacher wants us to read the values then do the math. This is what I have so far:#!/bin/bashvar1='cat File1'var2='cat File2'var3=`echo "scale=4; $var1 / $var2" | bc`echo The final result is: $var3

View 9 Replies View Related

Programming :: Sed Script - Searching For Text Within File / Replace With Variable

Feb 25, 2011

Code:
#!/bin/bash
VARR=`cat /proc/asound/cards | grep HDMI | cut -c 1-2`
VARX="defaults.ctl.card $VARR"
VARY="defaults.pcm.card $VARR"
FILE1="alsa"
FILE2="alsa.new"
echo $VARX
echo $VARY
sed "s/defaults.ctl.card*/'$VARX'/g" $FILE1 > $FILE2

This is what I have right now. Well, I thought I knew sed, and apparently I don't... I tried writing this for someone else, and this has given me trouble, so since the user pretty much figured it out on his own, here it goes.
Say VARR=1, so VARX and VARY contain the above text, appended by 1.
What I am trying to do is replace the text "defaults.ctl.card 0" by VARX and "defaults.pcm.card 0" by VARY. The contents of FILE1 is the file being used to search for both text fields, and FILE2 is the output file. I tried using single quotes, double quotes, and a mixture of both, and no go whatsoever. So my question... What is the proper way of searching for text within a file and replacing with a variable?

View 5 Replies View Related

Programming :: Parse Multiple Variable From Text File With Bash?

Jul 13, 2010

I am trying to think of a logic where my file contains some data I had to read and do some processing. Issue is that file contains data multiple times. For example:

:::::::::::
var1=value1
var2=value2

[code].....

I have to read first paragraph of variables and do some processing and then move on until the end of file. Variable names are same in whole file but for each paragraph the value is different. I can't think of a logic to attain this task. How can I do it? It should be a simple bash script, but I am not able to work out.

View 2 Replies View Related

Programming :: Initializing Arrays In The Bash?

Mar 12, 2009

I'm making script for automated compiling of one program which would output builds optimized for many architectures. For clearancy, I do each build in it's own catalogue and list of builds with their respective catalogues would be stored as array. I'm using this guide as reference. It describes making array as naming a variable with additional brackets denoting it's position in array.

In my code, it looks exactly like this:

Code:

mtune[1]="build/mtune/athlon"
mtune[2]="build/mtune/athlon-4"
mtune[3]="build/mtune/athlon-mp"

[code]....

But upon invoking $mtune or any $mtune[x] variable, output is blank, like the variable(s) were never initialized. What am I doing wrong?

View 1 Replies View Related

Programming :: Initializing Pmw Megawidgets For Python 2.6

Oct 12, 2010

I am having a problem initializing the Pmw megawidgets for Python 2.6.I have Pmw_1_3 loaded in the site-packages directory.

View 1 Replies View Related

Programming :: Make A New Variable With The String From The Old Variable Btut Without Any Plus Sign?

Apr 7, 2010

my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.

i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't

foo=+12.40
bar=${foo#+}

View 4 Replies View Related

Programming :: Error While Executing Scripts And Initializing Exe's?

Oct 13, 2010

I am having the following error while executing script and initialing my application

./ss.sh: line 1: kk.sh: command not found
./ss.sh: line 2: mon.exe: command not found

Can somebody assist ASAP.

View 4 Replies View Related

Programming :: C++ - Initializing Static Member Array?

Jun 7, 2011

The code below defines an array of structures in a class. I would like this to be a Static array and then initialize the array in a initialization method. I understand that initialization lists are the way to go but due to the size and complexity of the array I plan on using (the example below is a simple snippet that illustrates the problem) I would like to use the initialization method. However, I cant even get this thing to compile. The error says the reference to the ArrayOfStructs in the initialization routine is undefined.

l_long_Island

P.S. This is the error message

undefined reference to `ClassWithStaticArray::ArrayOfStruts'

class ClassWithStaticArray {
public:
struct IntegerStruct
{

[code]....

View 5 Replies View Related

Programming :: Initializing The SS Register (Intel Architecture)?

Jul 9, 2011

Kernel 2.6.21.5, slackware 12.0 as 2.17 [I am speaking here about 80x86 processors, with their segment registers SS, DS, CS, ES.] In a source file for as, I wrote

Code:

.section _STACK
.rept 4096
.word 0
.endr

Now, in the .text section, I want to initialize SS, the stack segment, to point to the _STACK section. In other assemblers, there was a special section for the stack, and the linker cared about initializing SS. Here I use a common section for the stack. For a segment such as DS, I could write

mov ax,_DATA
mov ds,ax

But I don't think mov ax,_STACK would do with as/ls.how do I initialize SS?

View 4 Replies View Related

Programming :: Get Eclipse C Compiler To Work - Warning: Implicit Declaration Of Function Strlen

Feb 11, 2009

I have the plugin installed ok and have pasted in a C source file that I know works and am getting the following errors, I think because the linker options need to be set in some way. I cannot copy the errors but they all complain of implicit declaration of functions like this: -

warning: implicit declaration of function strlen

But I have the headers included, is this a linker problem? Here is the code -

#include <stdio.h>
#include <math.h>
int main(){

[code]...

View 2 Replies View Related

Programming :: Search Within A Variable And Assign The Results To A New Variable?

Apr 25, 2011

how I can search within a variable and assign the results to a new variable. I'll use the following as an example -

cars="Audi BMW Cadillac Chevy Dodge Ferrari Ford Mercedes"
list=`echo ${cars} | egrep -o '<A?+|<C+'`

with the echo command I get the following output assigned to list -

A
C
C

What I'd like to get for output is -

Audi
Cadillac
Chevy

how I could do this regardless of upper/lower case letters?

View 5 Replies View Related

Programming :: Initializing My Application - Error While Loading Shared Libraries ?

Oct 14, 2010

While initializing my application the following errors is returned:

Bash profile for the user is as follows:

View 1 Replies View Related

Programming :: Initializing A Branch In One Launchpad Project On Multiple Computers?

Mar 25, 2010

initializing a branch in one Launchpad project on multiple computers, or even upon reinstalling an OS? I know I sure haven't.

View 1 Replies View Related

Programming :: Assign Value Of C Variable To Shell Variable?

Apr 28, 2010

included shell script inside c program, and i wanted to assign the value of c variable to shell variable..Can any one please suggest me how to do it?

View 8 Replies View Related

Software :: Get Variable From Text File Into Bash Variable?

Jun 10, 2009

I have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved