<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Werte ausgeben]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ein kleines Problem, ich muss von diesem String &quot;0 AZ 009049 001522300x&quot; , die Werte miteinader addieren z. B 0+ az + 009049 d.h nur die Werte, also in Bit und nicht als Sting ausgeben sonder eine addierte Bit Form.</p>
<p>weiss jemand wie?</p>
<p>Der Coder hier funktioniert gib aber nur Strings wieder. ( Dev C++)</p>
<pre><code class="language-cpp">#include &lt;vector&gt; 
#include &lt;string&gt; 
#include &lt;iostream&gt; 

using namespace std; 

int main( ) 
{ 
    const char str[ ] = &quot; 0 AZ 00-9049 0.01522300&quot;; 

    std::string temp( str ); 

    //std::string::size_type pos        = temp.find( ' ', 0 ); 
    //std::string::size_type old_pos    = 0; 

    std::vector&lt; std::string &gt; substrings; 
    int pos = 0;
    int start_pos = 0;
    int end_pos = 0;
    bool found = false;
    while(str[pos] != 0) { 
        if( (str[pos] &gt; 47 &amp;&amp; str[pos] &lt; 58) || (str[pos] &gt; 64 &amp;&amp; str[pos] &lt; 91)){
             if(found){
                 end_pos = pos+1;
             }
             else{
                 found = true;
                 start_pos = pos;
                 end_pos = pos+1;
             }
        }
        else{
             if(found){
                 substrings.push_back(temp.substr(start_pos, end_pos - start_pos));
                 start_pos = pos;
                 end_pos = pos;
                 found = false;
             }
        }
        pos++;

        //old_pos = ++pos; 
        //pos = temp.find( ' ', pos ); 

        //substrings.push_back( temp.substr( old_pos, pos - old_pos ) ); 
    } 

    for( std::vector&lt; std::string &gt;::size_type i = 0, size = substrings.size( ); i &lt; size; ++i ) { 

        std::cout &lt;&lt; i + 1 &lt;&lt; &quot;: &quot; &lt;&lt; substrings[ i ] &lt;&lt; std::endl; 
    } 

    system(&quot;PAUSE&quot;);
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/206146/werte-ausgeben</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 06:53:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/206146.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Feb 2008 15:50:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 15:50:57 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ein kleines Problem, ich muss von diesem String &quot;0 AZ 009049 001522300x&quot; , die Werte miteinader addieren z. B 0+ az + 009049 d.h nur die Werte, also in Bit und nicht als Sting ausgeben sonder eine addierte Bit Form.</p>
<p>weiss jemand wie?</p>
<p>Der Coder hier funktioniert gib aber nur Strings wieder. ( Dev C++)</p>
<pre><code class="language-cpp">#include &lt;vector&gt; 
#include &lt;string&gt; 
#include &lt;iostream&gt; 

using namespace std; 

int main( ) 
{ 
    const char str[ ] = &quot; 0 AZ 00-9049 0.01522300&quot;; 

    std::string temp( str ); 

    //std::string::size_type pos        = temp.find( ' ', 0 ); 
    //std::string::size_type old_pos    = 0; 

    std::vector&lt; std::string &gt; substrings; 
    int pos = 0;
    int start_pos = 0;
    int end_pos = 0;
    bool found = false;
    while(str[pos] != 0) { 
        if( (str[pos] &gt; 47 &amp;&amp; str[pos] &lt; 58) || (str[pos] &gt; 64 &amp;&amp; str[pos] &lt; 91)){
             if(found){
                 end_pos = pos+1;
             }
             else{
                 found = true;
                 start_pos = pos;
                 end_pos = pos+1;
             }
        }
        else{
             if(found){
                 substrings.push_back(temp.substr(start_pos, end_pos - start_pos));
                 start_pos = pos;
                 end_pos = pos;
                 found = false;
             }
        }
        pos++;

        //old_pos = ++pos; 
        //pos = temp.find( ' ', pos ); 

        //substrings.push_back( temp.substr( old_pos, pos - old_pos ) ); 
    } 

    for( std::vector&lt; std::string &gt;::size_type i = 0, size = substrings.size( ); i &lt; size; ++i ) { 

        std::cout &lt;&lt; i + 1 &lt;&lt; &quot;: &quot; &lt;&lt; substrings[ i ] &lt;&lt; std::endl; 
    } 

    system(&quot;PAUSE&quot;);
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1460329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460329</guid><dc:creator><![CDATA[Desi]]></dc:creator><pubDate>Thu, 21 Feb 2008 15:50:57 GMT</pubDate></item><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 15:54:01 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>In der FAQ hier in C++ Forum kannst du im Thread <em>Einmal String und zurück</em> nachlesen wie mal Strings in Integer umwandelt.<br />
Bei diesem Fall würde es sich lohnen ganz auf std::stringstream zu setzen.</p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460332</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460332</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Thu, 21 Feb 2008 15:54:01 GMT</pubDate></item><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 15:58:35 GMT]]></title><description><![CDATA[<p>Danke, ehm könntest du mir das ev. im Code zeigen, bin nicht so bewandert was Programmieren angeht. Danke</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460335</guid><dc:creator><![CDATA[Desi]]></dc:creator><pubDate>Thu, 21 Feb 2008 15:58:35 GMT</pubDate></item><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 16:06:30 GMT]]></title><description><![CDATA[<p>Hm, der Code kommt mir irgendwie bekannt vor <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>kennst du schon <code>std::isdigit( )</code> und co.?</p>
<p>greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460346</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460346</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 21 Feb 2008 16:06:30 GMT</pubDate></item><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 16:10:05 GMT]]></title><description><![CDATA[<p>hehe, nein es ist nicht mehr ganz der gleiche. Habe ihn zimmlich umgeändert. ausgeklammterte war deins *G*. nein kenn ich leider gar nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460350</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460350</guid><dc:creator><![CDATA[Desi]]></dc:creator><pubDate>Thu, 21 Feb 2008 16:10:05 GMT</pubDate></item><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 16:33:56 GMT]]></title><description><![CDATA[<p>Na dann, wolln wir mal...</p>
<pre><code class="language-cpp">#include &lt;cctype&gt; // isdigit( ), isupper( )
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

int main( )
{
	const char str[ ] = &quot; 0 AZ 00-9049 0.01522300&quot;;
	std::string temp( str );

	std::vector&lt; std::string &gt; substrings;

	std::string::size_type pos        = 0;
	std::string::size_type start_pos  = 0;
	std::string::size_type end_pos    = 0;   // Sollten alle drei std::string::size_type sein...

	bool found = false;

	while( str[ pos ] != 0 ) {

		// if( ( str[ pos ] &gt; 47 &amp;&amp; str[ pos ] &lt; 58 ) || ( str[ pos ] &gt; 64 &amp;&amp; str[ pos ] &lt; 91 ) ) {
		// 
		// leserlich:
		// if( ( ( '0' &lt;= str[ pos ] ) &amp;&amp; ( str[ pos ] &lt;= '9' ) ) || ( ( 'A' &lt;= str[ pos ] ) &amp;&amp; ( str[ pos ] &lt;= 'Z' ) ) )
		// 
		// besser:

		if( std::isdigit( str[ pos ] ) || std::isupper( str[ pos ] ) ) {

			if( found ) {

				end_pos = pos+1;

			} else {

				found = true;
				start_pos = pos;
				end_pos = pos+1;
			}

		} else {

			if( found ) {

				substrings.push_back( temp.substr( start_pos, end_pos - start_pos ) );
				start_pos = pos;
				end_pos = pos;
				found = false;
			}
		}

		pos++;
	}

	for( std::vector&lt; std::string &gt;::size_type i = 0, size = substrings.size( ); i &lt; size; ++i ) {

		std::cout &lt;&lt; i + 1 &lt;&lt; &quot;: &quot; &lt;&lt; substrings[ i ] &lt;&lt; std::endl;
	}

	std::cin.get( );
}
</code></pre>
<p>Erklär das Addiren mal anschaulich!</p>
<p>greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460370</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460370</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 21 Feb 2008 16:33:56 GMT</pubDate></item><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 16:59:16 GMT]]></title><description><![CDATA[<p>Danke dir!! du bist ein warer Held;)<br />
ehm aber gibt bei mir noch immer die Zahlen, in ascii aus nicht in bit *g*</p>
<p>habe es jetzt so gemacht</p>
<pre><code class="language-cpp">#include &lt;cctype&gt; // isdigit( ), isupper( )
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;iostream&gt;

int main( )
{
    const char str[ ] = &quot; 0 AZ 00-9049 0.01522300&quot;;
    std::string temp( str );

    std::vector&lt; std::string &gt; substrings;

    std::string::size_type pos        = 0;
    std::string::size_type start_pos  = 0;
    std::string::size_type end_pos    = 0;   // Sollten alle drei std::string::size_type sein...

    bool found = false;
    int sum = 0;

    while( str[ pos ] != 0 ) {

        // if( ( str[ pos ] &gt; 47 &amp;&amp; str[ pos ] &lt; 58 ) || ( str[ pos ] &gt; 64 &amp;&amp; str[ pos ] &lt; 91 ) ) {
        // 
        // leserlich:
        // if( ( ( '0' &lt;= str[ pos ] ) &amp;&amp; ( str[ pos ] &lt;= '9' ) ) || ( ( 'A' &lt;= str[ pos ] ) &amp;&amp; ( str[ pos ] &lt;= 'Z' ) ) )
        // 
        // besser:

        if( std::isdigit( str[ pos ] ) || std::isupper( str[ pos ] ) ) {
            sum += str[pos];
            if( found ) {

                end_pos = pos+1;

            } else {

                found = true;
                start_pos = pos;
                end_pos = pos+1;
            }

        } else {

            if( found ) {

                substrings.push_back( temp.substr( start_pos, end_pos - start_pos ) );
                start_pos = pos;
                end_pos = pos;
                found = false;
            }
        }

        pos++;
    }

    for( std::vector&lt; std::string &gt;::size_type i = 0, size = substrings.size( ); i &lt; size; ++i ) {

        std::cout &lt;&lt; i + 1 &lt;&lt; &quot;: &quot; &lt;&lt; substrings[ i ] &lt;&lt; std::endl;
    }
    std::cout &lt;&lt; &quot;The sum of the characters is &quot; &lt;&lt; sum &lt;&lt; std::endl;
    std::cin.get( );
}
</code></pre>
<p>Addiren??</p>
<p>Grüssle</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460382</guid><dc:creator><![CDATA[Desi]]></dc:creator><pubDate>Thu, 21 Feb 2008 16:59:16 GMT</pubDate></item><item><title><![CDATA[Reply to Werte ausgeben on Thu, 21 Feb 2008 17:13:02 GMT]]></title><description><![CDATA[<p>Ach Gott! Dein Programm gibt z. Zt. aus:</p>
<pre><code>0
AZ
00
9049
0
</code></pre>
<p>Du sagst: &quot;nur die Werte, also in Bit und nicht als Sting ausgeben sonder eine addierte Bit Form.&quot;</p>
<p>Wie sollen sie denn addiert und ausgegeben werden!?</p>
<p>a)</p>
<pre><code>0+0+9049+0 = 9040 =&gt; 10001101011001 (das Zahlensystem von 'AZ' kenn ich nicht...)
</code></pre>
<p>b)</p>
<pre><code>'0' =                0x37
          'A', 'Z' =           0x41 0x5A
          '0', '0' =           0x30 0x30
'9', '0', '4', '9' = 0x39 0x30 0x34 0x39
               '0' =                0x30
----------------------------------------
                     0x39 0x30 0xA7 0x53 =&gt; 111001001100001010011101010011
</code></pre>
<p>c) ??</p>
<p>greetz, Swordfish</p>
<p>PS: Was soll das eigentlich werden, wenn's fertig ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1460409</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1460409</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 21 Feb 2008 17:13:02 GMT</pubDate></item></channel></rss>