Hello,
I have some difficulty to understand the scope of this program adapted from C++ book of D.S. Malik I am reading.
I put the header and the main program as attachment to save space. My problem is the output:
I was expecting Line 9 part would be the same result as Line 9-2 part, but the sum of the two numbers is not right. It is difficult for me to understand why. The problem may be related to die::roll() and die::getNum() functions in this case, but I am not sure.
Also I am aware the rand() function here so each time the number will change. Can somebody elaborate it for me? Thanks a lot!
I'm having a problem getting this to work..
I got 3 files,
start.C - Where i got my main() function
Menu.C & Menu.h - Where I'm trying to use hash_map
start.C
#include <iostream>
#include "Menu.h"
using namespace std;
int main() { /* test code here */ return 0; }
Menu.h ... (1 Reply)
Each thread has a copy of auto variables within a function, but variables
declared as static within a function are common to all threads. To circumvent
this can static variables be placed outside the function. If so, will the
scope of the variable be file only or will it be extern, and will each... (7 Replies)
Hi ,
I'm trying to change the variable value in a while loop , however its not working it seems that the problem with subshells while reading the file.
#!/bin/sh
FLAG=0;
cat filename | while read data
do
FLAG=1;
done
echo $FLAG
Should display 1 instead displays 0 (13 Replies)
Hi,
I am stuck while developing a shell sub-routine which checks the log file for "success" or "failure". The subroutine reads the log file and checks for key word "success", if found it set the variable (found=1). It returns success or failure based on this variable.
My problem is, I can... (2 Replies)
Hi,
I want to know about the variable scope in shell script.
How can we use the script argument inside the function?
fn () {
echo $1 ## I want this argument should be the main script argument and not the funtion argument.
}
also are there any local,global types in shell script?
if... (3 Replies)
Hi, I'm trying to define an MPI_datatype for a structure, then do message passing for this created datatype. However, when I tried to broadcast the initialized data from rank 0, I found that part of the received data at other ranks are not correct. Could you please help me take a look at my code... (0 Replies)
Hello
I am having issues with a script I'm working on developing on a Solaris machine.
The script is intended to find out how many times a particular user (by given userid) has logged into the local system for more than one hour today.
Here is my while loop:
last $user | grep -v 'sshd'... (7 Replies)
Hello,
I met a problem with following code:
#!/usr/bin/perl -w
# test.pl
use strict;
use diagnostics;
use DBI;
my $dbh = DBI->connect(
"DBI:mysql:BibleBook","yifangt","password")
or die("Cannot connect: $DBI::errstr");
my $sql = qq(SELECT * FROM library WHERE isbn =... (2 Replies)