Programming :: String Deletes Its Own Value In C?

May 4, 2011

I have a school project to write a horse racing program, where the user can type their name, bet money, etc. However, after storing the user's name, it will delete itself after a few more instructions. So when I try to read back the user's name, it it blank. just this one section:

Code:

printw("Welcome. Name?
");
refresh();
scanw("%s",name1); //ask for name

[code]....

View 14 Replies


ADVERTISEMENT

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

Programming :: Pthread - Take String From The Command Line And Creates A Thread To Print The String

May 3, 2011

I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.

[Code]....

One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?

Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.

View 6 Replies View Related

Programming :: C Scanf Arbitrarily Deletes Contents Of Another Variable?

Oct 3, 2009

I am in the process of writing a program that plays the game mancala. I wanted to create a function that requires the player to choose a number between one and six, should be simple right? I kept having problems, so I started testing stuff out.

Code:

#include <stdio.h>
#include <stdlib.h>
short move();

[code]....

I am using gcc version 4.3.2 (Debian 4.3.2-1.1). On a whim, I tried something else out; when I change the 'short' variables to 'int' , the problem seems to dissapear.... I tried changing the format string in the scanf statement from "%d" to "%u" which is listed as the appropriate string for the 'short' type, still no luck.

View 13 Replies View Related

Programming :: Using Sed Replace Line Containing Particular String By A Single String?

Oct 16, 2010

I have a set of lines as ahown below:

Leon went to school
Leon came back from school..
Leon had dinner...

I have to replace the line containing "dinner" by a single string LUNCH...

View 2 Replies View Related

Programming :: Creates String Suffixes Out Of A Reference String?

Feb 25, 2011

I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be

1)bcdefg
2)cdefg
3)defg
and so on...

create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?

View 9 Replies View Related

Programming :: C - Put A Specific Arbitrary Part Of A String Into It's Own String?

Apr 18, 2010

So if I'm given a location of a file like:

How can I just take the type of the file at the end? I know I can use strrchr() for a period to get the pointer to the period just before file type. Is there a build in string function that will just take the rest of the string from a certain point on forward in the string? I know it wouldn't be much work to make it myself, but I figured I would find out if it already existed before doing it.

View 9 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 :: Shell Script That Deletes All Files Owned By A User?

Jan 14, 2010

the script should take as input in the begginig the username of the user and then deletes all the files and folders from the user in every place he has them. script must also check if the parameters have been given correctly (only one and that one must be a username) Doesnt all the files of a user exist on a folder with his name? what if i delete this folder? Will something like this work?

Quote:

E_NOARGS=65
if [ -z "$1" ] # Exit if no argument given.
then
echo "Usage: `basename $0` directory-to-copy-to"

[code].....

View 7 Replies View Related

Programming :: Assigning Custom String To Std::string In C++?

Oct 12, 2009

I've been given a custom-made string class which handles string, wstring and bstr. It has a number of methods and assignment operators to convert to and from different types. The app I work on compiles happily in VS6 and VS2008, but when trying to compile in Redhat (version 4.1.1 in Redhat 5.0)

[code]....

View 4 Replies View Related

Programming :: How To Check If All Letters Of One String Are In Another String?

Nov 11, 2010

I have the following two type of strings1: A/D2: A/C/DI am trying to write a subroutine to check whether all of the letters in string 1 appears in string 2. If yes, return true. If not, return false. In the above example, all the letters (A and D) in string 1 are also present in string 2, so I return true.

View 4 Replies View Related

Programming :: Convert The Int To A String Using Stringstream Then Convert The String To A Char?

Mar 26, 2011

Do I have the convert the int to a string using stringstream then convert the string to a char? or is there a more direct way?Also is there a way to tell the length of a int?

View 5 Replies View Related

Programming :: Serial Port Programming String?

Nov 24, 2010

I have a serial port program which is reading a string .if(read(readfd,sResult,1)>0)where sResult is unsigned char sResult[10];if sResult is array of 10 then iam getting string perfectly but if iam making sResult only as unsigned char I am getting NULL value CODE BELOW

Code:
unsigned char sResult;
main()
{
readfd = open("/dev/ttyUSB0", O_RDONLY);
if (readfd == -1)
{
perror("READ: open_port: Unable to open /dev/ttyUSB0-

[Code]...

View 2 Replies View Related

Programming :: Getting Substring Of The String?

Sep 13, 2010

I want normal substring of a string that actually is a url as follows

SITEURL/main.php?page=122&type=download_file&fileID=9&user Id=user1&org=org1&mainmenu=main1&submenu=sub1

What I want is a substring like below

org1_user1_main1_sub1

View 5 Replies View Related

Programming :: Which Effect Does $ Before String Have?

Dec 8, 2010

Which effect does the $ before the string have? This $ before a double-quoted string is used in many initscripts on Fedora 13, but not on Ubuntu 8.04.

View 2 Replies View Related

Programming :: Append To String In Awk?

Sep 20, 2009

I'm having problems completing my school exercises with awk.

Heres the desired outcome:

Code:

./my_awk 2
ACG GAG ATT AGG AGG ATC CCA CCA
CAC AGG ACG GAG ATT AGG AGG ATC

So it generates data in group of threes, 8 groups per row and prints it. My problem is that I can't seem to get awk to append stuff to string so I could print it nicely to screen. It just prints empty lines per the parameter given to it.

Heres my code so far:

Code:

#!/bin/sh
awk -v rows=$1 '
BEGIN {

[code]....

View 2 Replies View Related

Programming :: Convert String To Int ?

Jul 6, 2010

Iam trying to check a value less than or equals 0.The value iam getting is after doing grep a file . but its throwing error .

Code:

When i execute this it throws

Code:

View 8 Replies View Related

Programming :: Extract Value From String?

Dec 27, 2008

I need to extract a price from a string, this may vary in the future so it may be 12.99 or 14.99. i thought a sed command might crack it and i need to write to a file:<td><b class="priceLarge">?6.99</b>I need to extract the price 6.99(with no ?)so extract anyhting between "> and </B> and write it to a file such as tmp1.txt .

View 1 Replies View Related

Programming :: Get Value In Character String?

Oct 23, 2010

i am compiling the following program in linux. it's in c language. after the compilation with gcc when i run the executable file. it asks for input. but when i enter a name. i prints "Segmentation fault" and then terminate the program. can you please help me.

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

[code]....

View 1 Replies View Related

Programming :: Grep Not Getting Whole String?

Aug 23, 2010

I am trying to monitor how long an ldap search takes and maybe notify or something that a search takes longer than say 10 seconds.

Code:
tail -n 1000 /var/log/ldap.log
for SRCH in $( cat monitorldap.log |grep 'SRCH'); do
echo search string is
echo $SRCH

[Code]....

ok, so to start off with it doesn't appear to get the whole line, just a piece "Aug". How can I get the whole line into a variable so I can then cut it up into the pieces I need?

View 4 Replies View Related

Programming :: Getting String Value From Array?

Oct 29, 2009

I've got a problem...

a[0] = 22
echo $[a[0]]
echoes 22 - that works fine

[code]...

View 5 Replies View Related

Programming :: Put String On Top Of Text?

Jul 28, 2010

I want to create a script wherein it will put a string somewhere on the text file. I tried to create a script using redirect ">" and then put it on top of the file.

The text contains code...

View 6 Replies View Related

Programming :: Replacing String Using Awk?

Jan 19, 2010

i have a string of information displayed in this way :

Code:
John:king:20:34:60
what i am tring to do is to read in input which is given by the user and change it to the

[code]....

View 3 Replies View Related

Programming :: Sed (?) Insert String Between 2 Others?

May 21, 2010

I have a file like this:

Code:
/opt/local/some/dir/
blablablabiugfyugf

[code]....

View 10 Replies View Related

Programming :: Deleting Parts Of A String?

May 8, 2010

I'm trying to get my program to go through the string typed in by the user and strip it of EVERYTHING but the numbers. I can't place my finger on what I'm missing.

Code:
Code: #include<iostream>
#include<string>
using namespace std ;
int main()

[Code].....

View 2 Replies View Related

Programming :: Convert String To Int Array?

May 9, 2010

I've searched around and can't find out how to convert a string ( like "12345" ) into an int array ( x[ 5 ] = { 1, 2, 3, 4, 5 } ; ).

View 4 Replies View Related

Programming :: Delete Parentheses In A String?

Jul 1, 2010

I have the following string 1524)), I want to get rid of the parentheses. I have tried SED and AWK without success.
The last I tried was: echo "1526))" | sed 's/)).*$//'

View 4 Replies View Related

Programming :: Execute The String That Sed Actually Outputs?

Aug 2, 2010

I've been able to get the right output that I need from sed, but how can I execute the string that sed actually outputs?

View 3 Replies View Related

Programming :: Split A String By Every Nth Characters?

Jan 17, 2011

splitting a string by every nth characters. I'm using Python 2.7.1 because I'm using older libraries, if that matters.

For example, if this is my input:

Quote:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ac elit nibh, vitae venenatis ligula. Vestibulum a varius turpis.

Splitting it by every 10th character should produce this list:

Quote:

[ "Lorem ipsu", "m dolor si", "t amet, co", "nsectetur ", "adipiscing", " elit. Sed", " ac elit n", "ibh, vitae", " venenatis", " ligula. V", "estibulum ", "a varius t", "urpis." ]

View 6 Replies View Related

Programming :: Change String Variable In Awk?

Nov 26, 2010

How to change string variable in awk? for example, I parse with awk script text file named some_name_with_extension.txt

I want to print only some_name in my script

Code:
....
varCompName = FILENAME
print varCompName

How to put not all symbols from FILENAME to variable?

[Code].....

View 3 Replies View Related







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