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


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 :: Check If A Part Of String Exist

Sep 27, 2010

I have a macro which I use with ROOT. In this macro I want to check if a part of string exist so I can ignore it inside a loop. So, inside a loop I want to have something like:

Code:
if (string == "pre_ti_data_bdt*" || string == "pre_ti_data_nn*")
continue;

but of course I cannot use * in this piece of code! How to do this trick in C++?

View 5 Replies View Related

Programming :: Perl - Remove A Part Of String Unit1/U800/o

Apr 13, 2011

In a file,

I need to remove a part of string: /o

string:

or

the string can be

here I need to remove /d2

So, I need to remove everything after when I get last /

View 4 Replies View Related

Programming :: Need To Delete A Specific String

Aug 27, 2010

These must a be a question you received a lot, but I couldn't find a similar thread! It's a simple question.
I need to delete a specific string from a file. For example the specific numbers "3456" from a file. I've tried with the tr comand, using
Code:
tr -d '3456' file,
but it also deleted whichever ocurrence of 3,4,5,6 from my file. Should I use a regular expression?

View 7 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 :: 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 :: 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 :: Append Variable String In A Specific Line?

Jun 8, 2010

I want to append a variable string to the end of a specific line. not like append the same string to each line. like in my file i have 4 columns, i want to add a string in 5th column in some fixed row.

View 4 Replies View Related

Programming :: Use AWK To Search For A Specific String Inside Html?

Jan 26, 2010

how to search for a specific string of text inside an html document. I then want to cut out that specific data that the field or string contains. I want to do a shellscript that makes this function automaticly.

For example:

#
#Here i want to find the field "town" inside the html/java and then cut #out the town name from it and paste that to an file.
#
#

[Code].....

View 8 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

General :: Get Part Of A String In Bash ?

Mar 10, 2011

I've a string "this.is.a.name", and I would like to return "is.a.name". How can I do that in bash?

View 3 Replies View Related

Software :: [sed] Returns Whole String Instead Of Part

Jul 3, 2011

I'm not used to using "sed", but I need to use it to extract part of a string piped to it.

However, the "1" mentioned in the tutorials I read doesn't extract the token between the two brackets and returns the whole input string:

Code:
/tmp# echo "before [myfile.txt] after" | sed 's/[(.+)]/1/' before [myfile.txt] after

I expected simply "myfile.txt".

View 9 Replies View Related

General :: Return Part Of A String In Bash?

Mar 20, 2011

I would like to return the last part of a string in an array of strings in bash.

The array contains in each position the content below:

Code:
a.b.c
a.d.f
a
a.d

[Code].....

View 5 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

Software :: Replace A Text String In A File With A Random String - With Sed ?

Sep 2, 2010

I have a line in a text file that has 40 random characters within a tag and i want to change the characters to a new set of 40 random characters (alphanumeric a-z 0-9 etc)

The line in the text file looks like this:

Quote:

How would i go about doing that?

Also second question same as the above but how would i remove them instead of replacing them?

View 14 Replies View Related

Fedora :: Replace A String By A String In Text File?

Apr 26, 2011

If I have a word in a text file and I need to replace it by another word (for example, i need to replace abc by fff) so what is the command I can type it?

I am using vi editor.

View 3 Replies View Related

Ubuntu :: Put The String Sign Into File / String / Message (rsa)

Mar 7, 2011

I have a String that I would like to sign using a given RSA Private key. I thought this would be relatively easy but I have not been able to find out how to do it, unless I'm looking to far into a simple problem. Do i have to put the string into a file, and sign the file, or can i just sign the string/message?

View 7 Replies View Related

General :: Replace String With Empty String Of Dir Path ?

Apr 2, 2011

I want to replace a string of directory path in a string to empty:

Code:

But this doesnt seem to give me the desired thing:

Code:

This gives the desired outcome, but its specific, i need a variable in the sed not a string. And if I replace STRING="/mnt/sda1/record/$dd/" then I cant use it for something else, cause its has all the weird backslashes now.

View 3 Replies View Related

General :: Delete A Specific String In Vi?

Sep 16, 2009

How do i delete a specific string in vi? Suppose i want to delete only the instance "ing" occuring in a file through vi , how could i do this??

View 3 Replies View Related

General :: Remove Files That Contain A Specific String?

Feb 17, 2010

How can you remove files containing a specific string?I have...Code:find |grep 'string'This may return several results and I wanted to rm the results.I also have...Code:ls -l |grep 'string'|awk '{print $9}'which also may return results.But point is, I can't supply the results as a parameter to rmI was thinking of looping but I don't know how to access the results as if they were an array or something.

View 5 Replies View Related

General :: Extract A String Within A String Using A Pattern?

Nov 4, 2010

i have a file name using the following pattern:

PREFIX: AR
SOURCE: LEGACY
DATETIME: YYYYMMDD_HH24MISS
SUFFIX: .txt

sample filename:AR_LEGACY_20101104_105500.txti want to extract the source which is LEGACY in this case. how do i do this using shell?

View 1 Replies View Related

Fedora :: Adding String To File (a Specific Place) From CLI?

Jun 2, 2010

I have a script that among other things generates a makefile with an error that causes make to fail. specifically, the string "-Wimplicit-function-dec" should be changed a bit to "-Wimplicit-function-declaration". Is there a way to have bash add the new eight characters in the right place (on line 105)?

View 2 Replies View Related

General :: How To Find A File With Specific String Inside It

May 7, 2010

Is there any way i can find a file with specific word inside it.For example if i want to find a file which has some text written inside it.How would i form a command to search them?

View 5 Replies View Related

General :: Repacing A String At A Specific Location With Another In Vi (gVim)?

Mar 18, 2010

If i have a comma separated string like this one

Code:
aa,bb,cc,dd,ee
11,22,dd,3f,22

[code]....

View 6 Replies View Related

General :: Searching A Specific Directory For Files Containing A Text String?

Nov 20, 2010

I am a member of a group which has written a program whose source code is being held in a specific directory (~cs252/Assignments/basicAsst/project) and we want to go through and change the parameters for the function "sequentialInsert." My job is to find all occurances of the function call to "sequentialInsert" and to also list the files from where the code came from. Also, I have to be in the commandsAsst directory when I do this. I have tried grep and find combined together, and I am at a lost.

View 1 Replies View Related

Ubuntu :: Bash Script To Delete/replace A Specific String Of Text?

Jun 17, 2010

What i want to do is pretty simple.I want to uncomment every line that begins with "deb" (except for deb cdrom) in /etc/apt/sources.list.I know how to do this through system > administration > software sources.I know I can gksu gedit /etc/apt/sources.list.I'd rather not do it that way.I'd rather have a script do it. It's less work, less typing, less clicking, and would work the same on every ubuntu version.

View 8 Replies View Related

General :: Awk Gsub() Command - String (column) Manipulation - Replace The Value Of The $1 Column In The Awk Print String?

Mar 7, 2010

i use this script to get the time and date of back and fourth transactions for a particular execution id. I use a substr command on the 5th column to to cut the milli seconds off the time value. - otherwise the times would look like 08:30:04.235

grep <executionID> <auditfile> | awk '{ print $1, $2, $3, $4, substr($5,1,8}
FIX -> Mon 3/1/2010 08:30:04
FIX <- Mon 3/1/2010 08:32:36
FIX <- Mon 3/1/2010 08:35:08

[code].....

anyhow - i append two sed commands to further clarify the direction of the message.

awk '{ print $1, $2, $3, $4, substr($5,1,8} | sed -e 's/->/ ->IN/g' | sed -e 's/<-/<-OUT/g'
FIX -> IN Mon 3/1/2010 08:30:04
FIX <- OUT Mon 3/1/2010 08:32:36

[code]....

I tried using an awk gsub () command within the string instead of the two seds, but it did not work:

awk '{ print gsub(/<regex>/, <replace with>,$1), $2, $3, $4, substr($5,1,8}

the sed works ok, but it would be cooler to make the replacement within the awk command:

gsub(/->/,-> IN, $1)

Is there a way where i could replace the value of the $1 column in the awk print string?

View 1 Replies View Related







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