Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Merkkijonon käsittely c++

10 views
Skip to first unread message

Kale

unread,
Mar 7, 2009, 10:36:53 AM3/7/09
to
Mulla on stringi mj="aabbccddee"

tahdon kaivaa sieltä merkit bb jaa dd kahteen eri jonoon, mutta kuinka?


nikolas mäki

unread,
Mar 7, 2009, 2:03:10 PM3/7/09
to
Kale wrote:
> Mulla on stringi mj="aabbccddee"
>
> tahdon kaivaa sieltä merkit bb jaa dd kahteen eri jonoon, mutta kuinka?
>
>
1) Kävele merkkijonoa pitkin ja tutki jokainen merkki
2) kopioi alkuperäiseen jätettävät merkit tilapäiseen merkkijonoon
3) kopioi omiin merkkijonoihinsa siirrettävät niihin
4) kopioi tilapäinen merkkijono alkuperäisen paikalle


--
Muuten olen sitä mieltä, että suomen on erottava EU:sta.

Kale

unread,
Mar 8, 2009, 2:44:42 PM3/8/09
to
"nikolas mäki" <nichol...@hotmail.com> wrote in message
news:goug45$k1v$1...@nyytiset.pp.htv.fi...

Joo näin aattelinkin sen tehdä, mutta millä komennoilla merkkijonoa
tutkitaan?


Jari Kaija

unread,
Mar 8, 2009, 3:00:13 PM3/8/09
to
> Joo näin aattelinkin sen tehdä, mutta millä komennoilla merkkijonoa
> tutkitaan?

Sysutilsseista löytyy läjä vaikka ja mitä. Kyllä ne kääntäjän
helpeistä, jos moisessa on IDE, löytyy oikein helposti.

AnsiCompareStr

Compares strings based on the current locale with case sensitivity.

AnsiCompareText

Compares strings based on the current locale without case sensitivity.

AnsiDequotedStr

Converts a quoted string into an unquoted string

AnsiExtractQuotedStr

Converts a quoted string into an unquoted string.

AnsiLastChar

Returns a pointer to the last character in a string.

AnsiLowerCase

Returns a string that is a copy of the given string converted to lower case.

AnsiLowerCaseFileName

Converts a file name to lower case.

AnsiPos

Locates the position of a substring within an AnsiString.

AnsiQuotedStr

Returns the quoted version of an AnsiString.

AnsiSameStr

Compares AnsiStrings based on the current locale with case sensitivity.

AnsiSameText

Compares AnsiStrings based on the current locale without case sensitivity.

AnsiStrComp

Compares null-terminated character strings.

AnsiStrIComp

Compares null terminated character strings case insensitively.

AnsiStrLastChar

Returns a pointer to the last character in a null-terminated string.

AnsiStrLComp

Compares the first MaxLen bytes of two null-terminated strings,
case-sensitively.

AnsiStrLIComp

Compares two strings, case-insensitively, up to the first MaxLen bytes.

AnsiStrLower

Converts all characters in a null-terminated string to lower case.

AnsiStrPos

Returns a pointer to the first occurrence of a substring.

AnsiStrRScan

Returns a pointer to the last occurrence of a specified character in a
specified string.

AnsiStrScan

Returns a pointer to first occurrence of a character in a string.

AnsiStrUpper

Converts all characters in a null-terminated string to upper case.

AnsiUpperCase

Converts an AnsiString to upper case.

AnsiUpperCaseFileName

Converts a file name to upper case.

AppendStr

Appends a dynamically allocated string to an existing string.

Beep

Generates a message beep.

BoolToStr

Converts a Boolean value to an AnsiString.

ByteToCharIndex

Returns the position of the character that contains a specified byte in an
AnsiString.

ByteToCharLen

Returns the number of characters fully contained in the first MaxLen bytes
of an AnsiString.

ByteType

Indicates whether a byte in an AnsiString is a single byte character, the
first byte of a double byte character, or the second byte of a double byte
character.

ChangeFileExt

Changes the extension of a file name.

CharLength

Returns number of bytes used by a character.

CharToByteIndex

Returns the 1-based index of the first byte of a specified character in an
AnsiString.

CharToByteLen

Returns the length, in bytes, of the first MaxLen characters of an
AnsiString.

CompareMem

Performs a binary comparison of two memory images.

CompareStr

Compares two AnsiStrings case sensitively.

CompareText

Compares two AnsiStrings by ordinal value without case sensitivity.

CreateDir

Creates a new directory.

Currency and date/time formatting variables

Influence the way numeric or date/time values are formatted.

CurrentYear

Returns current year.

CurrToStr

Formats a Currency value as an AnsiString.

CurrToStrF

Converts a Currency value to an AnsiString, using a specified format.

Date

Returns the current date.

DateDelta constant

Specifies the difference between TDateTime and TTimeStamp values.

DateTimeToFileDate

Converts a TDateTime object to an OS timestamp.

DateTimeToStr

Converts a TDateTime value to an AnsiString.

DateTimeToString

Converts a TDateTime object to an AnsiString using a specified Format.

DateTimeToSystemTime

Converts a TDateTime object into the Win32 API's _SYSTEMTIME type.

DateTimeToTimeStamp

Converts a TDateTime object into the corresponding TTimeStamp structure.

DateToStr

Converts a TDateTime object to an AnsiString object.

DayOfWeek

Returns the day of the week for a specified date.

DecodeDate

Returns Year, Month, and Day values for a TDateTime object.

DecodeDateFully

Returns Year, Month, and Day, and Day-of-Week values for a TDateTime object.

DecodeTime

Breaks a TDateTime object into hours, minutes, seconds, and milliseconds.

DeleteFile

Deletes a file from disk.

DiskFree

Returns the number of free bytes on a specified drive.

DiskSize

Returns the size, in bytes, of a specified drive.

DisposeStr

Disposes of an AnsiString pointer that was allocated using NewStr.

EncodeDate; TryEncodeDate

Returns a TDateTime object that represents a specified Year, Month, and Day.

EncodeTime;TryEncodeTime

Returns a TDateTime object for a specified Hour, Min, Sec, and MSec.

ExceptionErrorMessage

Formats a standard error message.

ExcludeTrailingBackslash

Returns a path name without a trailing delimiter.

ExcludeTrailingPathDelimiter

Returns a path name without a trailing delimiter.

ExpandFileName

Returns the full path name for a relative file name.

ExpandUNCFileName

Returns the full path of a file name in UNC format, if appropriate.

ExtractFileDir

Extracts the drive and directory parts from FileName.

ExtractFileDrive

Returns the drive portion of a file name.

ExtractFileExt

Returns the extension portions of a file name.

ExtractFileName

Extracts the name and extension parts of a file name.

ExtractFilePath

Returns the drive and directory portions of a file name.

ExtractRelativePath

Returns a relative path name, relative to a specific base directory.

ExtractShortPathName

Converts a file name to the short 8.3 form.

FalseBoolStrs

Lists strings that can represent the boolean value false.

File open mode constants

File open mode constants are used to control the access mode to a file or
stream.

FileAge

Returns the OS timestamp of a file.

FileClose

Closes a specified file.

FileCreate

Creates a new file.

FileDateToDateTime

Converts an OS timestamp value to TDateTime object.

FileExists

Tests if a specified file exists.

FileGetAttr

Returns the file attributes of FileName.

FileGetDate

Returns an OS timestamp for a specified file.

FileIsReadOnly

Report if file is read-only.

FileOpen

Opens a specified file using a specified access mode.

FileRead

Reads a specified number of bytes from a file.

FileSearch

Searches a specified directory path for a file.

FileSeek

Repositions read/write point.

FileSetAttr

Sets the file attributes of a specified file.

FileSetDate

Sets the OS time stamp for a specified file.

FileSetReadOnly

Sets the file permissions to read-only.

FileWrite

Writes the contents of a buffer to the current position in a file.

FinalizePackage

Finalizes the specified package .BPL.

FindClose

Releases memory allocated by FindFirst.

FindCmdLineSwitch

Determines whether a string was passed as a command line argument to the
application.

FindFirst

Searches for the first instance of a file name with a given set of
attributes in a specified directory.

FindNext

Returns the next entry matching the name and attributes specified in a
previous call to FindFirst.

FloatToCurr ;TryFloatToCurr

Converts a floating-point value to a Currency value.

FloatToDateTime ;TryFloatToDateTime

Converts a floating-point value to a TDateTime value.

FloatToDecimal

Converts a floating-point value to a decimal representation.

FloatToStr

Converts a floating point value to an AnsiString.

FloatToStrF

Converts a floating point value to an AnsiString, using a specified Format,
Precision, and Digits.

FloatToText

Converts a floating-point value to an unterminated character string, using a
specified Format, Precision and Digits.

FloatToTextFmt

Converts a floating-point value to to an unterminated character string,
using a specified format.

FmtLoadStr

Returns formatted output using a resourced format string.

FmtStr

Assembles a formatted string using a format string and an array of
arguments.

Format

Returns a formatted string assembled from a format string and an array of
arguments.

FormatBuf

Formats the arguments from an array, placing the result in a buffer.

FormatCurr

Formats a Currency object.

FormatDateTime

Formats a TDateTime object.

FormatFloat

Formats a floating point value.

FreeAndNil

Frees an object reference and replaces the reference with NULL..

GetCurrentDir

Returns the name of the current directory.

GetEnvironmentVariable

Returns environment variable value.

GetFormatSettings

Resets the date and number format parameters to initial values.

GetPackageDescription

Returns the description resource from a package.

GetPackageInfo

Enumerates all the units and required packages for a package.

GUIDToString

Converts a class identifier GUID to an AnsiString.

IncAMonth

Increments date data by one month.

IncludeTrailingBackslash

Ensures path name ends with delimiter

IncludeTrailingPathDelimiter

Ensures path name ends with delimiter.

IncMonth

Returns a date shifted by a specified number of months.

InitializePackage

Validates and initializes a given package.

IntToHex

Returns the hex representation of an integer.

IntToStr

Converts an integer to an AnsiString.

IsDelimiter

Indicates whether a specified character in a string matches one of a set of
delimiters.

IsEqualGUID

Indicates whether two TGUIDs are the same.

IsLeapYear

Indicates whether a specified year is a leap year.

IsPathDelimiter

Indicates whether the byte at position Index of a string is the path
delimiter.

IsValidIdent

Tests for a valid C++ identifier.

Languages

Lists the locales for which support is available.

LastDelimiter

Returns the byte index in S of the last character that matches any character
in the Delimiters AnsiString.

LeadBytes variable

Lists all values that can be the first byte of a double byte character on
the local system.

LoadPackage

Loads a specified package.

LoadStr

Loads a string resource from the application's executable file.

LowerCase

Converts an ASCII string to lowercase.

MSecsToTimeStamp

Converts a specified number of milliseconds into a TTimeStamp value.

NewStr

Allocates an AnsiString on the heap.

NextCharIndex

Returns the byte index of the next character.

Now

Returns the current date and time.

NullStr constant

Declares a pointer to an empty string.

OutOfMemoryError

Throws an EOutOfMemory exception.

QuotedStr

Returns the quoted version of an AnsiString.

RaiseLastOSError procedure

Throws an exception for the last occurring OS or system library error.

RaiseLastWin32Error

Throws an exception for the last occurring Win32 error.

RemoveDir

Deletes an existing empty directory.

RenameFile

Changes a file name.

ReplaceDate

Replaces the date portion of a TDateTime value with a specified date.

ReplaceTime

Replaces the time portion of a TDateTime value with a specified time.

SafeLoadLibrary function

Loads a DLL while suppressing error dialogs and preventing the DLL from
changing the FPU control word.

SameFileName

Compares file names based on the current locale.

SameText

Compares two AnsiStrings by ordinal value without case sensitivity.

SetCurrentDir

Sets the current directory.

ShowException

Displays an exception message with its physical address

StrAlloc

Allocates a buffer for a null-terminated string and returns a pointer to its
first character.

StrBufSize

Returns the maximum number of characters that can be stored in a buffer
allocated by StrAlloc.

StrByteType

Indicates whether a byte in a string is a single byte character, the first
byte of a double byte character, or the second byte of a double byte
character.

StrCat

Appends a copy of Source to the end of Dest and returns the concatenated
string.

StrCharLength

Find character size.

StrComp

Compares two strings with case sensitivity.

StrCopy

Copies Source to Dest and returns Dest.

StrDispose

Disposes of a string.

StrECopy

Copies null-terminated string.

StrEnd

Returns a pointer to the end of a null terminated string.

StrFmt

Formats entries in an array.

StrIComp

Compares two strings without case sensitivity.

StringReplace

Returns an AnsiString with occurrences of one substring replaced by another
substring.

StringToGUID

Converts an AnsiString to a GUID.

StrLCat

Appends up to a specified maximum number of characters to string.

StrLComp

Compares up to a specified maximum number of characters in two strings.

StrLCopy

Copies up to a specified maximum number of characters from Source to Dest.

StrLen

Returns number of characters in a string excluding the null terminator.

StrLFmt

Formats a series of arguments from a specified array into a buffer.

StrLIComp

Compares strings up to a specified maximum number of characters, without
case sensitivity.

StrLower

Converts a string to lowercase.

StrMove

Copies specified number of characters to string.

StrNew

Allocates space on and copies a string to the heap; returning a pointer to
the string.

StrNextChar

Returns pointer to following character.

StrPas

Converts null-terminated string to an AnsiString.

StrPCopy

Copies an AnsiString to a null-terminated string.

StrPLCopy

Copies characters from an AnsiString into a null-terminated string.

StrPos

Returns a pointer to the first occurrence of STR2 in STR1.

StrRScan

Returns a pointer to the last occurrence of a specified character in a
string.

StrScan

Returns a pointer to first occurrence of a specified character in a string.

StrToBool

Converts an AnsiString to a Boolean value.

StrToBoolDef

Converts an AnsiString to a Boolean value, with error default.

StrToCurr

Converts an AnsiString to a Currency object.

StrToCurrDef

Converts an AnsiString to a Currency object, with error default.

StrToDate

Converts an AnsiString object to a TDateTime object.

StrToDateDef

Converts an AnsiString object to a TDateTime object, with error default.

StrToDateTime

Converts an AnsiString object to a TDateTime object.

StrToDateTimeDef

Converts an AnsiString object to a TDateTime object with error default.

StrToFloat

Converts a given string to a floating-point value.

StrToFloatDef

Converts a given string to a floating-point value with error default.

StrToInt64

Converts an AnsiString that represents an integer (decimal or hex notation)
to a number.

StrToInt64Def

Converts an AnsiString that represents an integer (decimal or hex notation)
to a number.

StrToInt

Converts an AnsiString that represents an integer (decimal or hex notation)
to a number.

StrToIntDef

Converts an AnsiString that represents an integer (decimal or hex notation)
to a number with error default.

StrToTime

Converts an AnsiString object to a TDateTime object.

StrToTimeDef

Converts an AnsiString object to a TDateTime object with error default.

StrUpper

Returns a string in upper case.

Supports

Indicates whether a given object or interface supports a specified
interface.

SysErrorMessage

Converts OS error codes into AnsiStrings.

SystemTimeToDateTime

Converts a _SYSTEMTIME value into a TDateTime objectvalue.

Time

Returns the current time.

TimeStampToDateTime

Converts a TTimeStamp value into the corresponding TDateTime object.

TimeStampToMSecs

Converts a TTimeStamp value into an absolute number of milliseconds.

TimeToStr

Returns an AnsiString that represents a TDateTime object.

Trim

Trims leading and trailing spaces and control characters from a string.

TrimLeft

Trims leading spaces and control characters from a string.

TrimRight

Trims trailing spaces and control characters from a string.

TrueBoolStrs

Lists strings that can represent the boolean value true.

TryStrToBool

Converts an AnsiString to a Boolean value, with Boolean success code.

TryStrToCurr

Converts an AnsiString to a Currency object, with Boolean success code.

TryStrToDate

Converts an AnsiString object to a TDateTime object, with Boolean success
code.

TryStrToDateTime

Converts an AnsiString object to a TDateTime object with Boolean success
code.

TryStrToFloat

Converts a given string to a floating-point value with Boolean success code.

TryStrToInt64

Converts an AnsiString that represents an integer (decimal or hex notation)
to a number.

TryStrToInt

Converts an AnsiString that represents an integer (decimal or hex notation)
to a number with Boolean success code.

TryStrToTime

Converts an AnsiString object to a TDateTime object with error default.

UnixDateDelta constant

Specifies the difference between TDateTime and TIME_T values.

UnloadPackage

Unloads a package.

UpperCase

Returns a copy of an AnsiString in uppercase.

WideCompareStr

Compares Unicode strings based on the current locale with case sensitivity.

WideCompareText

Compares Unicode strings based on the current locale without case
sensitivity.

WideFmtStr

Assembles a formatted Unicode string using a format string and an array of
arguments.

WideFormat

Returns a formatted Unicode string assembled from a format string and an
array of arguments.

WideFormatBuf

Formats the arguments from an array, placing the result in a buffer.

WideLowerCase

Returns Unicode string converted to lower case.

WideSameStr

Compares Unicode strings based on the current locale with case sensitivity.

WideSameText

Compares Unicode strings based on the current locale without case
sensitivity.

WideUpperCase

Returns Unicode string converted to upper case.

Win32Check

Checks the return value of a Windows API call and throws an appropriate
exception when it indicates failure.

Win32Platform variable

Specifies the Win32 platform identifier.

WrapText

Splits an AnsiString into multiple lines as its length approaches a
specified size.


Aggro

unread,
Mar 8, 2009, 3:47:16 PM3/8/09
to
Kale wrote:

> Joo näin aattelinkin sen tehdä, mutta millä komennoilla merkkijonoa
> tutkitaan?

Esimerkiksi näin:

#include <string>
int main()
{
std::string str = "abc";
if( str[0] == 'a' )
{

}
return 0;
}

Voit tietty myös etsiä merkkijonosta tiettyä merkkijonoa, esim. find():n
avulla, täällä on esimerkki:
http://www.cppreference.com/wiki/string/find

Tästä listasta voi löytyä muuta mielenkiintoista:
http://www.cppreference.com/wiki/string/start

Petteri Kautonen

unread,
Mar 9, 2009, 1:39:56 AM3/9/09
to
Jari Kaija kirjoitti:

>> Joo näin aattelinkin sen tehdä, mutta millä komennoilla merkkijonoa
>> tutkitaan?
>
> Sysutilsseista löytyy läjä vaikka ja mitä. Kyllä ne kääntäjän
> helpeistä, jos moisessa on IDE, löytyy oikein helposti.
>
> AnsiCompareStr

Taitaa muo Ansi-alkuiset olla C++ Builder -/ Delphi-spesifisiä.

nikolas mäki

unread,
Mar 9, 2009, 3:32:15 PM3/9/09
to

Netistä löytyy vaikka mitä c++ -juttua. Myös mikkisoftan nettisivuilta
voi etsiä c/c++ -juttua. Tietysti on se vanhanaikainen paperivaihtoehto:
joko kirjan osto tai kirjastosta lainaus.

Matti Lehtiniemi

unread,
Mar 10, 2009, 3:15:42 AM3/10/09
to
> Voit tietty myös etsiä merkkijonosta tiettyä merkkijonoa, esim. find():n avulla, täällä on esimerkki:
> http://www.cppreference.com/wiki/string/find
>
> Tästä listasta voi löytyä muuta mielenkiintoista:
> http://www.cppreference.com/wiki/string/start

Jos on vanha c-ohjelmoija , niin string:stä saa c_str() :n avulla vanhan
C-mallisen stringin.
Sitten voi käyttää strcmp () funktioita jne.

Mutta ei kai tuon find():n ja substr():n opettelu nyt kovin vaikeaa ole.

Matti

0 new messages