Programming :: Comparison Between Pointer And Integer

Jul 6, 2010

I'm trying to write a simple program that lists a menu and then asks you for your decision, and you can answer with a number or the name. However, I don't know how to add the second options (name).

View 14 Replies


ADVERTISEMENT

Programming :: Pointer To Pointer Segmentation Fault?

Jun 27, 2009

I have been googling trying to fix this ... basicly I have a (int **) variable, and when I try to pass a (int) value to a specific position, I have seg.fault.Resuming what I have is:

int ** p;
p[0][0] = 1; //segmentation fault

View 7 Replies View Related

Programming :: Comparing String With Integer?

Sep 19, 2010

If I have a variable, say xvar, which can take both string and integer value and I want to perform an operation in following 2 conditions:1. Either xvar is null2. xvar equals 2[ -z "$xvar" ] || [ $xvar -eq 2 ] && <some-code>Doesn't seem to work if xvar takes string valuesI know that since I have no restriction on xvar, I can get away with string comparison in second test too, ie[ -z "$xvar" ] || [ "$xvar" = "2" ] && <some-code>
But, 'Sams teach yourself shell script in 24 hrs' says that [ expr1 -eq expr2 ], if either is string, it assumes 0 valueIs it true

View 5 Replies View Related

Programming :: Concatenating An Integer To A String?

Oct 18, 2010

I have a function that take char* I call this function in an array, and I need to pass the following:-i+" binomial" to be like "2 binomial" or whatever value of i value (i is an integer) it is pretty easy to be done in java, but how to concatenate an integer with a string and get char* or string to pass to a new function.If you missed me i just need to get the following :string =integer + string

View 5 Replies View Related

Programming :: Split File When Integer Is Found

Jun 25, 2010

I have a file in which contains one line with a lot floating points.In the very first place and some times in the downstream, there are a few integers, surrounded by blank spaces.1 1.02-4 1.03-5 544 1.04-1 65 2.98-1 5.78-10 3.45-2 etc etc.I aim to split the file in more files each of them containing an integer and the following floatings until the next integer.

View 1 Replies View Related

Programming :: In C Program The Value Of An Integer Variable Is Changing Rapidly

May 12, 2010

In a c program the value of an integer variable is changing rapidly. I have to get the value of that variable at a particular instant from another program. How can i do it without using a file?

When i tried with extern variable as

I execute the both .c file from 2 terminals but got only value 0 printed for both var_a and var_b all the time .

View 4 Replies View Related

Programming :: Java - Doesn't Hold Integer Values

Apr 27, 2011

I have a java compiler and Im using a double intiger called Experience and when compiled and run the double intiger does not hold intiger values that are mathameticle. Like 1.5 - 1.4 will equal .100000000000000000009 and 5/3 will equal 1.0. and 1.5x 1.4 doesnt equal 2.1. Is there something I am doing wrong with double intigers? Is it the compilers fault? Could it be something thats wrong with my computer and the compilers I am using are not tat fault? Anyways double 1.5 + 1.4 does equal 2.9 so.

View 4 Replies View Related

Programming :: C Function Not Returning An Integer After Comparing It To A Char?

Jan 23, 2010

I've got a strange bug that I cannot figure out how to solve. Here is the function.

Code:
int getnexttab(char input[], int index, int length)
{

[code]....

View 14 Replies View Related

Programming :: How To Convert Negative Integer To Byte Array?

Oct 26, 2010

I need to convert an integer to a byte array of size 2 and vice versa. The code shown below works well for positive values but not for negative values. Also, using an array of size four makes the conversion works. However, I am limited to an array of size 2.

View 5 Replies View Related

Programming :: Multithreaded Reading And Writing Of A Shared Integer?

Nov 4, 2010

It it safe to read a shared integer while another thread is writing to it on a multicore system?

View 3 Replies View Related

Programming :: Print A Single Digit Integer On To The Screen Using The Int 0x80?

Jul 4, 2010

I want to print a single digit integer on to the screen using the int 0x80. I have loaded the number in the ecx(=5, say), size in edx (=4, lenght) and eax (=4) ebx (=1). I've added 48 to the contents of ecx, and then calling int 0x80, I thought should print 5 on the screen.

However it does not print anything. also gives no errors. I checked the contents of the ecx reg (gdb), it has 53.

A snippet showing the this will be great. I've seen snippets using the c library (printf), but I want to see how it is done using int 0x80.

View 9 Replies View Related

Programming :: Getting A Comparison Operator To Work?

Feb 8, 2010

I'm very new at Bash scripting and have a bone head issue that I'm trying (and failing) to resolve. I cannot get this one IF statement to work, it seems the comparison operator does not think the resulting number from the $b*$c+$b operation is an integer even though it is a number. Below is a small proof of concept script with the bit I'm having trouble with.

Code:
#! /bin/bash
a=800
b=700
c=.15
if [ "$a" -le "$(echo "($b*$c+$b)"|bc)" ]

[Code]...

View 6 Replies View Related

Programming :: Operator For Floating Point Comparison?

May 10, 2011

I know it is wrong to use the "==" operator to compare the equality of two floating point numbers. Logically it would seem that if the "==" operator is not usable for floating point comparison, then the "<=" operator would also not be usable. Is this true? The lack of google search results on this topic made me think that it must be true. If that is true, then is it true that the only way to compare floats with <= or >= is with something like the code below? Code: bool smaller_than_or_equal(float a, float b) {

if ( fabs(a-b) < EPSILON){return true;}
else if (a < b) {return true;}
else {return false;}

} I think this is a general question, but if specifics are necessary, I am using the C++ language to code at the moment.

View 5 Replies View Related

Programming :: Comparison And Breaking Out Of Loop Java?

Oct 10, 2010

my issue is that the when i put in the correct input its going into the loop like i put in incorrect input and wont break out of the loop even with the correct input entered

Code:
import java.util.*;
import javax.swing.*;

[code]...

View 3 Replies View Related

Programming :: Bash Scripting With File Date Comparison?

Mar 23, 2011

I need to be able to compare a file date with system date and delete files older than 30 days.

the file name is basically
error_log.03222011

of course the extension is the date the file was created.

Oh and before i get hammered I looked everywhere but am unable to make sense of what I found.

View 3 Replies View Related

Programming :: Bash Time Comparison Within A Fast Moving Log?

Jun 1, 2010

I have a bash script that is tracking ERROR connections (running in a cron every 15 minutes), sometimes the errors are true and are not connecting. But most of the time, the disconnects/reconnects are between 30 seconds are sending out false positives. I am looking for a time comparison code to pick out the 30 second disconnects and know that this is and "ok" error. Here is a section of the log with timestamps, errors, etc.

Tue 2010-06-01 22:01:30 ERROR [DataBufferSendService] 172.31.0.1:8016 caught exception: [NetworkAPI] Exception: [SocketStream] socket error
Tue 2010-06-01 22:01:32 ERROR [DataBufferSendService] 172.31.0.2:8016 caught exception: [NetworkAPI] Exception: [SocketStream] socket error
Tue 2010-06-01 22:02:00 INFO [Client] 172.31.0.1:8016 connecting to 172.31.0.1 on port 8016
Tue 2010-06-01 22:02:02 INFO [Client] 172.31.0.2:8016 connecting to 172.31.0.2 on port 8016

View 8 Replies View Related

Programming :: Script For Executing A Program And Doing String Comparison

May 6, 2009

I am fairly new to linux still and I'm currently trying to write a shell script (which I have never done) that is supposed to run the xrestop(like top) program. What I want to do is execute the program and check the identifier column to see if a certain program is running. If it is running I want to strip the data from that row of the terminal say every 5 seconds or so and put it in a text file. Is this going to be a complicated thing?

Heres a list of the columns when you run xrestop program res-base Wins GCs Fnts Pxms Misc PxmMem Other Total PID Identifier.

View 9 Replies View Related

Programming :: String Comparison - [: =: Unary Operator Expected?

Nov 23, 2010

I would like to compare the nmlookup result of IP's stored in the file ips with a list of PC names stored in the file pcs.

Code:
for line in `cat "ips"`
do

[code]....

View 2 Replies View Related

Programming :: String Comparison - Get Regular Expression To Work In If / Else Statement?

Jun 29, 2010

how do I get this regular expression to work in an if/else statement? This is just a little script for learning BASH. don't be too harsh.

This script will test if a certain number of files with 1-4 in their filename exist and print their filename. An error message will be printed if not.

#
for i in `ls file[1-9]`
do
if [[ "$i" == *1-4 ]] ; then
echo "This file, $i, ends in a number between 1-4"
else
echo "Error, this file, $i, does not end with a number between 1-4"
fi
done

I get this error. ./file_test.sh: 13: [[: not found

View 2 Replies View Related

Programming :: Shell Script Comparison For Two File(text) Character Wise?

Mar 1, 2010

I need to write a shell script which can compare two files(text files) character wise. eg. underscore is space.

------FILE 1---------------
A_B_C
D_E_F
G_H_I

[code].....

Actual problem: I need to write a shell script which can give me difference character by character not by line (using comm)

View 4 Replies View Related

Programming :: Convert String To Integer Back To String C++ ?

Mar 13, 2010

Code:

The error is:

Code:

What I want to do is take input of ip4 as a string, convert it to an integer to add 1 to it, then reconvert it back to a string. Its not working.

My full code is:

Code:

View 1 Replies View Related

Programming :: Asm 64bit Registers - "64-bit Linux Allows Up To Fourteen Parameters To Be Transferred In Registers (6 Integer And 8 Floating Point)."

Mar 28, 2010

I have tried to learn how 64bit asm (nasm in my case) works and found, among the many disparate pieces of info on the net, a few vague inferences that floating point registers can be used for other purposes than what they are intended for, example: "64-bit Linux allows up to fourteen parameters to be transferred in registers (6 integer and 8 floating point)." This would be fantastic for string operations/manipulation (I have never used asm for floating-point operations), can anyone shed a bit of light?

View 8 Replies View Related

Programming :: C++ Check If Pointer Is Deleted?

Apr 24, 2011

Is it possible to check if a pointer is deleted in C++ (using GDB)? For example:

Code:
a = new Thing();
b = a;
delete a;

// If all I have is the variable "b", how can I tell if it was deleted?

View 14 Replies View Related

Programming :: C - Malloc For A Void Pointer?

Mar 20, 2010

So far I have this:

Code:
int mm_init (mm_t *MM, int hm, int sz) {
int i;

[code]...

View 4 Replies View Related

Programming :: Null Pointer In Bash?

May 19, 2011

#!/bin/bash
sed -n 8p file.txt

returns the 8th line to the StdOut.

If I assign the value to the variable line = $(sed -n 8p file.txt)

and now print it out with echo

echo $line

the line would be printed.

But what if the file has only 4 lines. What value would be assigned to the variable line?

I want to know that because I want to only print it if the value is "something", that is not null.

In Java for example I would do it like this...
String line = "";
line = reader.readLine(); // or anything else..
if(line!=null){
System.out.println(line);
}

How would I check if the value is not "null"(I don't know if bash knows null)

View 13 Replies View Related

Programming :: Pointer To Array Of Integers?

Aug 23, 2009

Code:
#include <stdio.h>
int main ()

[code]...

View 7 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 :: Access The Address Of A Character Pointer?

Jul 12, 2010

i was trying to access the address of the character pointer it gives me the values stored in the variable.

Code: #include<iostream>
using namespace std;
int main()
{
char *i;

[Code]....

why is my code not giving the address of the variable i when it is a character pointer.

View 2 Replies View Related

Programming :: Pointer As Function Return Doubt?

Jul 15, 2010

I'm getting some information about C language and this session of a C book (follow the above link) is using a bad example for me. When I'm trying this example of function returning a pointer, my compiler is stating a warning that I return a pointer to a local variable. I realized that it is error prone after all this variable may be override before the function has done his execution. And the author is fooling me saying that this example is "perfectly safe". I'm wrong? There is something that I don't got yet? Sorry but this site is preventing me to post the link of book cause I'm a newbie, so a need the hack it. Just strip out the question signs:

{LINK}
?w?w?w
?cs.cf.ac.uk?

[code]....

View 6 Replies View Related

Programming :: Assign Absolute Address To Pointer

Dec 20, 2010

I want to assign an address location to a pointer and wanted to display the value at that memory location.I wrote a small program for this and it is like this : (i am using gcc 4.4 compiler)

# include "stdio.h"
int main()
{
unsigned int *a;
a=(unsigned int *)0x3f8;
printf("%u",*a);
return 0;
}

But it is giving Segmentation fault

View 14 Replies View Related







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