<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Linux Forum &mdash; String и скобки]]></title>
	<link rel="self" href="https://linuxforum.ru/extern.php?action=feed&amp;tid=30775&amp;type=atom" />
	<updated>2013-10-03T18:13:35Z</updated>
	<generator>PunBB</generator>
	<id>https://linuxforum.ru/viewtopic.php?id=30775</id>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367350#p367350" />
			<content type="html"><![CDATA[<p>не. не забанили пока. Продолжаем веселье.</p><p>И да, C++ всё равно не рекомендую. Что вам в сишечке не нравится? Char* вполне годная замена стрингов. Сам Линус юзает, и нахваливает. И шлёт всех к такой-то матери, кто пожелает C++, или прочую ересь.</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2013-10-03T18:13:35Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367350#p367350</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367312#p367312" />
			<content type="html"><![CDATA[<p>Ладно...</p>]]></content>
			<author>
				<name><![CDATA[viva_linuxoid]]></name>
				<uri>https://linuxforum.ru/profile.php?id=31832</uri>
			</author>
			<updated>2013-10-03T17:19:30Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367312#p367312</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367218#p367218" />
			<content type="html"><![CDATA[<p><strong>viva_linuxoid</strong>, думаю -- не нужно. Тема C++ очень сложна, и у меня нет времени её раскрывать. Да и здешние вахтёры наверное скоро меня опять забанят...</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2013-10-03T12:21:04Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367218#p367218</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367212#p367212" />
			<content type="html"><![CDATA[<p>Можно поточней ?</p>]]></content>
			<author>
				<name><![CDATA[viva_linuxoid]]></name>
				<uri>https://linuxforum.ru/profile.php?id=31832</uri>
			</author>
			<updated>2013-10-03T12:07:24Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367212#p367212</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367200#p367200" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>viva_linuxoid пишет:</cite><blockquote><p>А на c++</p></blockquote></div><p>а на C++ есть стандартная STL, в которой есть нужный вам std::string. Но можно сделать и свой, с картами и девочками.</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2013-10-03T11:50:32Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367200#p367200</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367199#p367199" />
			<content type="html"><![CDATA[<p>можно сделать свою структуру (<em>struct</em>) string, и написать кучу функций для обработки этой структуры.</p><p>ещё можно считать строкой указатель на символ. С двумя допущениями:</p><p>1. это не просто указатель на символ, а указатель на массив, который имеет достаточный для строки размер.</p><p>2. строка оканчивается на \0, и в ней нет символов \0. И размер массива достаточен не только для строки, но и для \0 в конце.</p><p>тогда с такими &quot;строками&quot; можно юзать библиотеку glibc, и все функции, перечисленные в третьем разделе man pages. Например<br /></p><div class="fancy_spoiler_switcher"><div class="fancy_spoiler_switcher_header" data-lang-open="открыть спойлер" data-lang-close="скрыть спойлер"><strong>+</strong>&nbsp;открыть спойлер</div><div class="fancy_spoiler"><p>STRCPY(3)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Linux Programmer&#039;s Manual&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;STRCPY(3)</p><p>NAME<br />&nbsp; &nbsp; &nbsp; &nbsp;strcpy, strncpy - copy a string</p><p>SYNOPSIS<br />&nbsp; &nbsp; &nbsp; &nbsp;#include &lt;string.h&gt;</p><p>&nbsp; &nbsp; &nbsp; &nbsp;char *strcpy(char *dest, const char *src);</p><p>&nbsp; &nbsp; &nbsp; &nbsp;char *strncpy(char *dest, const char *src, size_t n);</p><p>DESCRIPTION<br />&nbsp; &nbsp; &nbsp; &nbsp;The&nbsp; strcpy() function copies the string pointed to by src, including the terminat-<br />&nbsp; &nbsp; &nbsp; &nbsp;ing null byte (&#039;\0&#039;), to the buffer pointed to by dest.&nbsp; The strings may not&nbsp; over-<br />&nbsp; &nbsp; &nbsp; &nbsp;lap,&nbsp; and&nbsp; the&nbsp; destination&nbsp; string&nbsp; dest must be large enough to receive the copy.<br />&nbsp; &nbsp; &nbsp; &nbsp;Beware of buffer overruns!&nbsp; (See BUGS.)</p><p>&nbsp; &nbsp; &nbsp; &nbsp;The strncpy() function is similar, except that at most n bytes of src&nbsp; are&nbsp; copied.<br />&nbsp; &nbsp; &nbsp; &nbsp;Warning: If there is no null byte among the first n bytes of src, the string placed<br />&nbsp; &nbsp; &nbsp; &nbsp;in dest will not be null-terminated.</p><p>&nbsp; &nbsp; &nbsp; &nbsp;If the length of src is less than n, strncpy() writes additional null bytes to dest<br />&nbsp; &nbsp; &nbsp; &nbsp;to ensure that a total of n bytes are written.</p></div></div>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2013-10-03T11:49:14Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367199#p367199</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367197#p367197" />
			<content type="html"><![CDATA[<p>А на c++</p>]]></content>
			<author>
				<name><![CDATA[viva_linuxoid]]></name>
				<uri>https://linuxforum.ru/profile.php?id=31832</uri>
			</author>
			<updated>2013-10-03T11:46:49Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367197#p367197</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367193#p367193" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>viva_linuxoid пишет:</cite><blockquote><p>А с библиотеками можно как-то создать строковую переменную в си ?</p></blockquote></div><p>нет.</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2013-10-03T11:41:15Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367193#p367193</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367190#p367190" />
			<content type="html"><![CDATA[<p>Хм...<br />А с библиотеками можно как-то создать строковую переменную в си ?</p>]]></content>
			<author>
				<name><![CDATA[viva_linuxoid]]></name>
				<uri>https://linuxforum.ru/profile.php?id=31832</uri>
			</author>
			<updated>2013-10-03T11:33:13Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367190#p367190</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367184#p367184" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>viva_linuxoid пишет:</cite><blockquote><p>Я хотел спросить что дают скобки после имени метода</p></blockquote></div><p>1. Это <em>функция</em> называется. Методы в C++.<br />2. ничего не дают. Это просто синтаксис. В паскале вот пишут begin, end. В bash&#039;е пишут вот так:<br /></p><div class="codebox"><pre><code>case a in b
...
esac

if command; then
...
fi</code></pre></div><p>ну а в C <em>блок</em> (несколько операторов) отделяют скобками.</p><p>например<br /></p><div class="codebox"><pre><code>if(УСЛОВИЕ)
{
  ОПЕРАТОР1;
  ОПЕРАТОР2;
}</code></pre></div><p>оба оператора выполняются тогда, и только тогда, когда УСЛОВИЕ истинно (т.е. не равно нулю в C).<br /></p><div class="quotebox"><cite>viva_linuxoid пишет:</cite><blockquote><p>как создать переменную string в си</p></blockquote></div><p>никак.</p><p>Можно только сделать массив из символов.</p><div class="codebox"><pre><code>const char str[] = &quot;test string&quot;;</code></pre></div><p>такой массив имеет тип <strong>char*</strong>, оканчивается символом \0, и его нельзя менять.</p><p>Можно сделать массивы и так, что-бы их содержимое можно было менять (но не размер)<br /></p><div class="codebox"><pre><code>char str2[256];</code></pre></div><p>PS: сейчас набегут тролли, и скажут, что размер менять можно. Я знаю. В новом стандарте иногда можно. Но не нужно.</p><p>PPS: да, ещё можно выделить память функцией malloc(3) и потом удалить free(3).</p><p>PPPS: сейчас набигут... Короче, если кто набижать хочет -- лучше расскажите сами.</p>]]></content>
			<author>
				<name><![CDATA[drBatty]]></name>
				<uri>https://linuxforum.ru/profile.php?id=86</uri>
			</author>
			<updated>2013-10-03T11:26:11Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367184#p367184</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[String и скобки]]></title>
			<link rel="alternate" href="https://linuxforum.ru/viewtopic.php?pid=367176#p367176" />
			<content type="html"><![CDATA[<p><strong><em>доброго времени и суток !!!</em></strong><br />Я хотел спросить что дают скобки после имени метода и как создать переменную string в си (чистом си).<br />заранее спасибо.<br />(давно мучают эти вопросы)</p>]]></content>
			<author>
				<name><![CDATA[viva_linuxoid]]></name>
				<uri>https://linuxforum.ru/profile.php?id=31832</uri>
			</author>
			<updated>2013-10-03T10:30:18Z</updated>
			<id>https://linuxforum.ru/viewtopic.php?pid=367176#p367176</id>
		</entry>
</feed>
