C++ :: Echo Meaning In Bash Scripting

Apr 1, 2014

What does echo in a bash script mean?

The code I'm trying to understand says:

for((m=0; m<1;m++))
do
#assign the correct mechanism to run
RMFilename=${Mechanisms[m]}

[Code] .....

View 3 Replies


ADVERTISEMENT

C++ :: What Is Meaning Of Typesafe

Dec 23, 2013

what is meaning of typesafe in c++..........and what is type safety.........

View 3 Replies View Related

C++ :: How To Use Next Bash Function

Jul 21, 2014

I'm new in C++ and sure - I'm learning it.

But - just interesting - how next bash function can't looks like in C++?

This code used to check array of system global variables:

Code:

#!/usr/bin/env bash
# defining and fill array
variables=( [1]=$sysvar1
[2]=$sysvar2
[3]=$sysvar3
[4]=$sysvar3
)
# function
checkvars () {

[Code]...

# start function with array as argument checkvars "${variables[@]}" It's simple enough and I hope C++ code will not be too complicated for me to understand it :-)

P.S. Goal of post - not really made some job for me - but show an example of some C++ code, which I'll can sort out and compare with bash code. Some explanations will be nice.

View 4 Replies View Related

C++ :: Output Compiled Script Into Binary File - Scripting Tool Algorithms

Dec 25, 2014

I am working on a script compiler that must output compiled script into binary file. Compiling etc is not a problem. The problem is detecting some specific cases. Nothing seems to work. If it works, then it breaks as soon as i modify the script.

Here is example "script1":

Code:
1VAR1 c1 = 44
2VAR2 c2 = 66
3beginscript
4if(c1=44)
5do_nothing

[Code] ....

Second example "script2", when there can be also some command between ENDIF and ENDIF. In this case: do_nothing command.

Code:
1VAR1 c1 = 44
2VAR2 c2 = 66
3beginscript
4if(c1=44)
5do_nothing

[Code] ....

The INDEXES before each line are not in actual script. They are just to point YOU to specific lines. Although the INDEXes are in compiled script!! This is very important. As you see there can be simple IF_ENDIF and nested (more complex) IF_ENDIF.

i.e IF_ENDIF inside another IF_ENDIF.

There are also IF_ELSE_ENDIF and some other ones, but im trying to make simple IF_ENDIF work first.

ENDIF is "SPECIAL" command, the IF, DO_NOTHING are "usual" commands.

"Usual" commands must always jump over(!) the ENDIF. ALWAYS!!

They must "ignore" them!

One strong RULE is like this for usual commands: always jump over any ENDIF, not matter what. If there is one, two or more ENDIF's in a row, then just jump over them to the closest NEXT usual block command. If there is some "usual" block command between multiple ENDIFs, then jump to this command and this command must therefore check whats next command right after it. And do the same: check if next command is ENDIF, if yes, jump over it, until "usual" block command is found.

This is the place im stuck. When i some time ago thinked about some ideas, i saw some patterns. One of them was that: Seems like if its nested IF_ENDIF, then every usual block command jumps out of it, i.e. right after the final ENDIF of this current nested IF_ENDIF.

But as soon as i added do_nothing between the two ENDIFs the so called "pattern" broke. In script2 above you see index 11 is do_nothing. Ok its in nested IF_ENDIF it should jump out to command index 17. But no, because there is do_nothing between index 13 and 16. If we jump out at index 11, the command 14 would never execute. This is a BIG NO. One idea i was thinking and trying was to use STL::FIND, STL::FIND_IF to find next "usual" command after specific index. But my code seems to crash sometimes and not work always.

Code:
bool NextNonENDIF(int i) {
return (i!=98);
}
int findNextBlockCmd(vector<int>&vec, int curidx)

[Code] ....

Here i pass him the vector that contains all the command TYPES in current script. Each command has its own TYPE or better called unique ID in which way compiler knows what is what. So in this case im trying to find a command thats NOT "ENDIF", in other words im trying to find next usual command after specific type of command. Lets just say the TYPE or unique ID of do_nothing is 555, im trying to find it.

How i should continue with this? What to use maybe stl::stack, some custom command indexing, some sort of labelling for usual commands in nested IF_ENDIFs or what?

In general, look script2, and i ask: There is index 11, this guy should look if there is any usual block command left for him before the final ENDIF at index 16. If there is, jump to it. If there is none, jump out of this nested IF_ENDIF to index 17.

Question: how to do it? What algorithms to use? I can use STL, BOOST, whatever. And i can use C++11.

View 1 Replies View Related

C++ :: Make Command In Bash Terminal

Nov 27, 2014

I've recently refreshed my mac by reinstalling the operating system. Uploaded the previous C and C ++ source scripts I was working with but when I go to compile them through the bash terminal it says command not found? Im not sure whats going because I thought that all the gcc files were already available? What am I messing here.

View 5 Replies View Related

C/C++ :: Echo Not Printing

Mar 9, 2014

A simple UNIX shell that supports some built-in commands, external commands, and file redirection.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

[Code]....

View 6 Replies View Related

C :: Scanf / Fgets Without Echo

Aug 31, 2014

I am trying to write a terminal-like chat application in Linux. I would like to use a FIFO queue to print out the messages in terminal. The queue would be populated from 2 sources- stdin and messages sent from the other user over TCP. I have meet an obstacle that I cannot handle...

Lets say I would like to take user input using fgets and put it into a buffer. Then queue it if the buffer is not empty or print if it is. The problem is that when I use fgets or scanf, my input is instantly printed to the terminal..If i do:

Code:

fgets(message, 100, stdin); printf

("%s", message The string under message is printed twice :|. Is there a way to prevent this?

View 5 Replies View Related

C++ :: Displaying A Text File (Echo)

Jul 19, 2013

So I'm really stuck trying to figured this bug on the program that is preventing me from displaying the text of my program..

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <stdio.h>

using namespace std;
int main () {
ifstream infile;
ofstream offile;

[Code] ....

View 3 Replies View Related

C++ :: Echo String Entered By User

Oct 3, 2013

/*
* echoString2.c
* Echoes a string entered by user. Converts input to C-style string.
*/

#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(void) {
char aString[200];
char *stringPtr = aString;

[Code] ....

and these are my errors

212Untitled1.cpp[Error] stray '222' in program
212Untitled1.cpp[Error] stray '' in program
212Untitled1.cpp[Error] stray '222' in program
262Untitled1.cpp[Error] stray '222' in program
262Untitled1.cpp[Error] stray '' in program
262Untitled1.cpp[Error] stray '222' in program
Untitled1.cppIn function 'int main()':
2125Untitled1.cpp[Error] 'n' was not declared in this scope

View 3 Replies View Related

C++ :: Call Function Syntax To Be Equivalent To Echo

Aug 19, 2014

What I want to do is simple, however I can not find a way to do it in c++ and I don't know for sure that it is possible. I want to create a function that creates a simple short-hand for printf(x); Such as:

void echo(x){
printf(x);
}

But when I call the function:

echo "hi";//I want it to look like this
//instead of:
echo("hi");// like this.

View 2 Replies View Related

C++ :: Program Will Echo Letter (User Input) And Output Name Of The Day Of Week

Oct 21, 2012

Write a C++ program that does the following:

Prompt the user to enter a day of the week as M (or m), T, W, R, F, S, and U for Monday through Sunday respectively. The user may enter an upper or lower case letter.

When the user enters a character, the program will echo the letter and output the name of the day of the week.

Provide an error trap that reads something like "you have entered an invalid letter; program aborting." Suggestion: use a switch statement with the error trap as the default condition. it is not necessary to prompt for multiple inputs.

So I know how to get the program to echo back the letter and everything. What I am a little confused about is: will I have to define all the letters as their respective day? eg. make M== Monday. And if I do have to do that how would I get it to accept Upper and Lower case letters and recognize that that letter is == monday ect. ect.

Also my main problem is the switch statement as the error trap. I have never used the switch statement, but I know what they do. I just don't really understand how I would use it for an error trap. Am I suppose to just make a case for every other letter in the alphabet other then M T W R F S and U? Even if I do that then what if the user enters a number instead of a letter?

View 4 Replies View Related







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