Programming :: ANSI C Code Seg-faults When Unsigned Int Variable Is Used?

Feb 20, 2011

I'm writing a tridiagonal solver for sparse linear systems and I coded this decreasing loop:

PHP Code:

xx[NN - 1] = gamma[NN - 1]*BB[NN - 1];
ii = NN - 2;
/* Compute the x values: */
while (ii >= 0) {
xx[ii] = gamma[ii]*(BB[ii] + xx[ii + 1]);
ii = ii - 1;


now... if ii is declared as an unsigned integer, the code gives me a segmentation fault, but if I declare it as an int, it doesn't. Using DDD I noticed that, as an unsigned int variable, when I finally decrease it, it underflows and blows up to a huge value, ergo giving me an unaccesible direction for xx in the following iteration! I taugh me not to use unsigned int variables for dereasing loops! XD

View 14 Replies


ADVERTISEMENT

Programming :: Char Variable Is Behaving As Unsigned Char?

Feb 14, 2011

i define variable of type char (range -128 to 127). when i tried to print the value after assigning a -ve value to it it displaying a +ve value of that -ve value(256+value).

View 3 Replies View Related

Programming :: How To Use Bash Variable In C Code?

Feb 16, 2011

I want to write a c program with some shell scripts.Now For a simple C program. I am Setting a variable called val2 in bash, now I want to use bash variable val2 in C code. How do I do that?The above doesn't work (coz its spawning a different memory space and when shell script ends the variable dies with it as per my research but how do I keep them in same memory space)Also Is there any Good reference where they teach how to integrate C and Bash Together?

View 5 Replies View Related

General :: Terminal That Supports ANSI Italic Escape Code?

Oct 29, 2010

I would like to replace gvim with vim in the terminal. One of the nice things about gvim is that it is able to display text using italics.

Vim allows setting an ANSI escape code for italics (e[3m), but this does not work in gnome-terminal. Is there a terminal emulator that supports the ANSI escape code for italics?

View 1 Replies View Related

Programming :: Book To Learn Programming In C ANSI?

Jul 11, 2011

What book you recommend to learn programming in C ANSI ?

View 1 Replies View Related

Programming :: Explorations In Memory Allocation In ANSI C?

Feb 8, 2011

I'm performing some explorations in terms of memory allocations in ANSI C, using the following compiler:

gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)

and I started to try to make the compiler complain for a huge data structure, so I coded this:

[code]....

I mean, I can always read the man entry for gcc but I rather ask because I can then have interaction...

View 11 Replies View Related

Programming :: Unsigned Integers In C?

Mar 24, 2009

From what I understand, if I attempt to increment an unsigned int which is already at its max value, it will flip back to zero.Question: is this guaranteed to happen by the C language? That is, can I count on this happening on all platforms?(Of course, I recognize that the max value of the int will change from platform to platform...)

View 5 Replies View Related

Programming :: MySQL Unsigned Character?

Jan 8, 2010

I am trying to create a table T having a field F which should be able to store variable-length sequences of "unsigned" characters (8bit values ranging from 0 to 255 (not including 0, including 255)).(MAX_LENGTH) is not working, as it seems to want sequences of 8bit values ranging from 0 to 127 (thus "signed" characters).Can anyone help me by pointing out if there is a type suited for my needs (or if such a type does not exist)?For those familiar to C programming and working with the MySQL client library, I should be able to (successfully) do something along the lines of:

Code:
unsigned char value[] = { 'H', 'E', 'L', 'L', 'O', -1, -128, 'W', 'O', 'R', 'L', 'D' };
unsigned char query[255];

[code]....

View 3 Replies View Related

Programming :: Copying Unsigned Char To Uint64_t?

Oct 17, 2010

I am a dummy in C programming. I have a problem with copying the array of 64 elements of unsigned char to array of 8 element of uint64_t. For example:

unsigned char p[64]
uint64_t Data[8];
memcpy (&Data, &p, 64);

I am not sure if it is right. Please help me. Thanks a lot.Moreover, do both p and Data have 64 bytes?

View 2 Replies View Related

Programming :: Srand (static_cast<unsigned Int>(clock( ))); Seems Not Random Enough

Jul 21, 2011

I copied and test a simple random number generate program

#include <algorithm>
#include <vector>
#include <iterator>
#include <iostream>

[code]....

View 2 Replies View Related

Programming :: Saving A PPM File - Binary Representation Of Unsigned Chars On The Harddrive

Apr 7, 2010

I am accessing a firewire camera using the libdc1394 library and saving the image as a PPM file, using the code below:

[Code].....

My question is whether the above code is portable. I presume it is, since the result is a binary PPM file which should be capable of being read across multiple computers with different architectures and different operating systems. But at the same time, all that the above code is doing is just saving the binary representation of unsigned chars on the harddrive, and there does not seem to be any reason why the binary representations of the unsigned chars will be identical across multiple computers.

View 1 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 :: 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 :: 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 :: 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

Programming :: Parallel Matrix - Matrix Multiplication Seg-faults?

Apr 13, 2011

I just can't find... why is my code seg-faulting?

PHP Code:
/*
Code name: Assignment #7.
File name: slice.c
Program name: Matrix multiplication (parallel version).
Version: 1.

[Code]...

Is giving my a seg-fault right at the ending point where I do the final gather from the MASTER processor.

View 9 Replies View Related

Programming :: Selenium Java Code Into Equivalent Php Code?

Mar 30, 2011

I need to rewrite the selenium java code into its equivalent php code.

View 5 Replies View Related

Programming :: Assignment To A Variable Variable?

Mar 17, 2011

This loop is part of a bash script which takes multiple arguments.

Code:
for ((i=1;i<=$number;++i)) ; do
offset=$(($i+5))

[code]...

View 3 Replies View Related

Programming :: Convert A Char * To Unsigned Char?

Mar 4, 2010

is it possible to convert a variable from char * to unsigned char ?

View 5 Replies View Related

Programming :: Pass Variable In Mysql Qyery In C Programming?

Dec 4, 2010

i want to pass variable in mysql qyery in c programming

View 1 Replies View Related

Fedora :: ANSI BBS In Gnome Terminal ?

Sep 24, 2010

I am a former Sysop of a BBS and currently resurrecting the BBS. I have been looking for a way to get Gnome Terminal in Fedora 13 configured to support ANSI BBS emulation.

Back in the DOS days, we just loaded ANSI.SYS and ran our terminal software (like Procomm Plus or Qmodem), but I am hoping someone has done this and can help me set it up.

I have already tried Qterrm and the "latest" syncterm. Neither of these worked right. Syncterm hasn't been updated since 2009, so I really don't want to mess too much with that one.

I know you can terminal.app in Mac OS X to do it, so I figure we can too. I REALLY want gnome terminal to be the way to do it.

View 5 Replies View Related

Software :: Less - ANSI Colors And Search

Aug 2, 2010

I'm having an annoying issue with less. What I want is to view logs with important stuff color coded, and be able to correctly use less's search function.

What happens is that less correctly displays color coded text, but offsets the search highlighting.

For instance, if I run "ls -l --color=always | less -R", and then search for some text, the highlighting will be offset if that text (or any text before it) is colored.

I tried forcing LESSANSIENDCHARS by doing a "export LESSANSIENDCHARS=m", but that didn't work.

"less --version" gives me "less 382+iso254", and I am running "SUSE LINUX Enterprise Server 9 (x86_64)".

View 3 Replies View Related

Software :: Apache2 Error.log Seg Faults?

Jan 12, 2009

On my Debian Etch server, I'm finding a lot of the following in my /var/log/apache2/error.log file:

Code:
[Mon Jan 12 09:34:17 2009] [notice] child pid 17217 exit signal Segmentation fault (11)
[Mon Jan 12 09:34:18 2009] [notice] child pid 17206 exit signal Segmentation fault (11)
[Mon Jan 12 09:34:18 2009] [notice] child pid 17216 exit signal Segmentation fault (11)

What is a good way to trouble shoot and remedy this problem? We can't have processes dying all over the place, now can we.

View 6 Replies View Related

CentOS 5 :: Segmentation Faults With Yum, Logrotate, And Others?

Dec 4, 2010

Recently I noticed that on my Centos 5.4 system, yum no longer works and is giving segmentation faults. I can run "yum --help" and it works, but if I try to run something like "yum upgrade php" it will fault. I also noticed that other things are seg faulting as well, like /usr/sbin/logrotate and /usr/bin/certwatch.

I am guessing there is some sort of common library that needs fixing, but I have no idea what. I've read other posts about the yum segmentation fault and have tried various steps provided but so far no luck in getting it to work again. It used to work, and I rarely change this system so I'm not sure what could have caused it.

View 2 Replies View Related

General :: Printing Transcript With Ansi Escape Sequence?

Aug 8, 2010

Is there a way to print a transcript generated using script that is coloured using ansi escape sequences while preserving the colours?

I am on OS X 10.6, but any tool that works on OS X or on Linux that can print or create a pdf file will be extremely helpful.

View 1 Replies View Related

Software :: Text Editor To Display ANSI Color?

Mar 7, 2009

I'm looking for a text editor that when displaying a document will parse any ANSI color codes it comes across into the correct colors rather than just show the codes in the ^[[xx;xx;xxm format

can anyone recommend something?

View 3 Replies View Related

Ubuntu :: Razerd Segmentation Faults In Maverick?

Nov 23, 2010

I have am using Maverick Meerkat 10.10 Kernel version: 2.6.35-22-generic I have a Razer DeathAdder gaming mouse. I am trying to compile/run this tool: Razer config tool I have jumped through several hoops:[URL]..

This install was for 10.04. This link helped with taming the mouse a little:[URL]..

Code:
xinput --set-prop "Razer Razer DeathAdder" "Device Accel Constant Deceleration" 5
Code:
xinput --set-prop "Razer Razer DeathAdder" "Device Accel Velocity Scaling" 1

I get the program to compile (after some problems the usb.h file not being where the system said it was) and I install it following these instructions in the README file that I have attached. I get a segmentation fault error when the razer daemon razerd tries to start:
[Code]...

View 9 Replies View Related

Ubuntu :: Segmentation Faults From Random Programs?

Mar 2, 2011

I have an annoying problem with Ubuntu 10.10 64bit. I made a clean installation of Ubuntu on my LG P310 laptop and I'm using the Nvidia proprietary driver. The problem is that I get segmentation faults from random program after a while of usage. Examples of programs are Thunderbird, Synaptic, apt-get and tap crashes in Chromium (which I would think is segmentation faults). It would seem like a underlying library is causing the faults. The problem disappear after a reboot, the faults might only occur after a wakeup from suspend, I'm not sure about that at the moment. I can't figure out what triggers these faults, and I don't know how to do error tracing in this case.

View 5 Replies View Related

General :: Redefine The Way ANSI Colors Are Shown In A Terminal Emulator?

Jun 8, 2011

I'd like to redefine the actual colors that ANSI escape sequences show, i.e. I'd like to personalize what "light red" means and render it as, say, orange. Is there any terminal emulator that works under linux that allows me to do this? how?

View 1 Replies View Related

Programming :: Sed A Variable In Bash?

Mar 25, 2011

I have beat this enough and don't get what should have been a very simple thing to do. I build a variable;

Code:
CLIST=java,lua,python,php,perl,ruby,tcl
CLIST will be used by another bash script but I need to replace the commas with a space. I

[code]...

View 2 Replies View Related







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