<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lalit Kumar</title>
    <description>The latest articles on DEV Community by Lalit Kumar (@whataluckyguy).</description>
    <link>https://dev.to/whataluckyguy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F518991%2F6184c90d-ac51-40f6-a74b-e945729a64a2.jpeg</url>
      <title>DEV Community: Lalit Kumar</title>
      <link>https://dev.to/whataluckyguy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/whataluckyguy"/>
    <language>en</language>
    <item>
      <title>How to display selected value of drop down list in HTML</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:57:43 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/how-to-display-selected-value-of-drop-down-list-in-html-49km</link>
      <guid>https://dev.to/whataluckyguy/how-to-display-selected-value-of-drop-down-list-in-html-49km</guid>
      <description>&lt;p&gt;Solution: You can simply use JavaScript to display the selected value or text from a drop-down list. Let us follow this step&lt;/p&gt;

&lt;h2&gt;
  
  
  STEP 1: Create a drop box list
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;select id="country"&amp;gt;
    &amp;lt;option value="None"&amp;gt;-- Select --&amp;lt;/option&amp;gt;
    &amp;lt;option value="ID001"&amp;gt;China&amp;lt;/option&amp;gt;
    &amp;lt;option value="ID002" selected&amp;gt;United State&amp;lt;/option&amp;gt;
    &amp;lt;option value="ID003"&amp;gt;Malaysia&amp;lt;/option&amp;gt;
&amp;lt;/select&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/213/how-to-display-selected-value-of-drop-down-list-in-html"&gt;https://kodlogs.com/blog/213/how-to-display-selected-value-of-drop-down-list-in-html&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  STEP 2: Display option value
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var e = document.getElementById("country");
var result = e.options[e.selectedIndex].value;
alert(result); //ID002
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  STEP 3: Display option text
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var e = document.getElementById("country");
var result = e.options[e.selectedIndex].text;
alert(result); //United State
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  STEP 4: JavaScript drop-down code
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;JavaScript - Get selected value from dropdown list&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;

    &amp;lt;body&amp;gt;

        &amp;lt;h1&amp;gt;JavaScript - Get selected value from dropdown list&amp;lt;/h1&amp;gt;

        &amp;lt;p id="result"&amp;gt;United State&amp;lt;/p&amp;gt;

        &amp;lt;select id="country"&amp;gt;
            &amp;lt;option value="None"&amp;gt;-- Select --&amp;lt;/option&amp;gt;
            &amp;lt;option value="ID001"&amp;gt;China&amp;lt;/option&amp;gt;
            &amp;lt;option value="ID002" selected&amp;gt;United State&amp;lt;/option&amp;gt;
            &amp;lt;option value="ID003"&amp;gt;Malaysia&amp;lt;/option&amp;gt;
        &amp;lt;/select&amp;gt;

        &amp;lt;script&amp;gt;

            function GetSelectedValue(){
                var e = document.getElementById("country");
                var result = e.options[e.selectedIndex].value;

                document.getElementById("result").innerHTML = result;
            }

            function GetSelectedText(){
                var e = document.getElementById("country");
                var result = e.options[e.selectedIndex].text;

                document.getElementById("result").innerHTML = result;
            }

        &amp;lt;/script&amp;gt;

        &amp;lt;br/&amp;gt;
        &amp;lt;br/&amp;gt;
        &amp;lt;button type="button" onclick="GetSelectedValue()"&amp;gt;Get Selected Value&amp;lt;/button&amp;gt;

        &amp;lt;button type="button" onclick="GetSelectedText()"&amp;gt;Get Selected Text&amp;lt;/button&amp;gt;
    &amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://kodlogs.com/blog/213/how-to-display-selected-value-of-drop-down-list-in-html"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>How to generate pdf file from dynamic data coming from MySQL database in PHP</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:41:37 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/how-to-generate-pdf-file-from-dynamic-data-coming-from-mysql-database-in-php-cef</link>
      <guid>https://dev.to/whataluckyguy/how-to-generate-pdf-file-from-dynamic-data-coming-from-mysql-database-in-php-cef</guid>
      <description>&lt;p&gt;We can generate the pdf form MySQL database by using FPDF which allows generating the pdf files without using any library. We can generate by considering the following steps;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download the FPDF library from fpdf.org.&lt;/li&gt;
&lt;li&gt;Generate the database teacher in the MySQL database.&lt;/li&gt;
&lt;li&gt;Connect to the database by using the connection.php file.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Connection.php
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Class dbObj{

var $dbhost = "localhost";

var $username = "root";

var $password = "";

var $dbname = "test";

var $conn;

function getConnstring() {

$con = mysqli_connect($this-&amp;gt;dbhost, $this-&amp;gt;username, $this-&amp;gt;password, $this-&amp;gt;dbname) or die("Connection failed: " . mysqli_connect_error());

if (mysqli_connect_errno()) {

printf("Connect failed: %s\n", mysqli_connect_error());

exit();

} else {

$this-&amp;gt;conn = $con;

}

return $this-&amp;gt;conn;

}

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Index.php:
&lt;/h3&gt;

&lt;p&gt;Now generate the index.php file which will generate the invoice of that number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;

&amp;lt;html lang="en"&amp;gt;

&amp;lt;head&amp;gt;

&amp;lt;meta charset="UTF-8"&amp;gt;

&amp;lt;title&amp;gt;PDF file&amp;lt;/title&amp;gt;

&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;

&amp;lt;h2&amp;gt;Generate PDF&amp;lt;/h2&amp;gt;

&amp;lt;form class="form-inline" method="post" action="generate_pdf.php"&amp;gt;

&amp;lt;button type="submit" id="pdf" name="generate_pdf" class="btn btn-primary"&amp;gt;&amp;lt;i class="fa fa-pdf"" aria-hidden="true"&amp;gt;&amp;lt;/i&amp;gt;

Generate PDF&amp;lt;/button&amp;gt;

&amp;lt;/form&amp;gt;


&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Generate_pdf.php:
&lt;/h3&gt;

&lt;p&gt;Now we will create the generate_pdf.php file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
include_once("connection.php");

include_once('libs/fpdf.php');

class PDF extends FPDF

{

function Header()

{

    $this-&amp;gt;Image('logo.png',10,-1,70);

    $this-&amp;gt;SetFont('Arial','B',13);

    $this-&amp;gt;Cell(80);

    $this-&amp;gt;Cell(80,10,'Employee List',1,0,'C');

}
function Footer()

{
   $this-&amp;gt;SetY(-15);

    $this-&amp;gt;SetFont('Arial','I',8);
    $this-&amp;gt;Cell(0,10,'Page '.$this-&amp;gt;PageNo().'/{nb}',0,0,'C');

}

}

$db = new dbObj();

$connString =  $db-&amp;gt;getConnstring();

$display_heading = array('id'=&amp;gt;'ID', 'employee_name'=&amp;gt; 'Name', 'employee_age'=&amp;gt; 'Age','employee_salary'=&amp;gt; 'Salary',);

$result = mysqli_query($connString, "SELECT id, employee_name, employee_age, employee_salary FROM employee") or die("database error:". mysqli_error($connString));

$header = mysqli_query($connString, "SHOW columns FROM employee");

$pdf = new PDF();
$pdf-&amp;gt;AddPage();
$pdf-&amp;gt;AliasNbPages();

$pdf-&amp;gt;SetFont('Arial','B',12);

foreach($header as $heading) {

$pdf-&amp;gt;Cell(40,12,$display_heading[$heading['Field']],1);

}

foreach($result as $row) {

$pdf-&amp;gt;Ln();

foreach($row as $column)

$pdf-&amp;gt;Cell(40,12,$column,1);

}

$pdf-&amp;gt;Output();

?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://kodlogs.com/blog/130/generate-file-from-dynamic-data-coming-from-mysql-database"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>PHP capitalize first letter of each word</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:38:14 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/php-capitalize-first-letter-of-each-word-ceh</link>
      <guid>https://dev.to/whataluckyguy/php-capitalize-first-letter-of-each-word-ceh</guid>
      <description>&lt;p&gt;In this topic, we will learn and explore how can we capitalize on the first letter of each word in PHP .PHP has a variety of inbuilt functions to make things easy and in a quick manner. PHP has a variety of inbuilt functions to deal with strings which help us to perform our desired task efficiently. Let’s discuss one of the best and a very helping method of PHP to capitalize on each first character of each word of a given string.&lt;/p&gt;

&lt;h2&gt;
  
  
  Capitalizing the first letter of each word by using the ucwords() function.
&lt;/h2&gt;

&lt;p&gt;PHP introduced the ucwords () function in its 4th version to process strings, and to assist the programmers in capitalizing the first letter of each word. Here we are going to discuss its syntax and how it works. We will check this method with examples.&lt;/p&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/2599/php-capitalize-first-letter-of-each-word"&gt;https://kodlogs.com/blog/2599/php-capitalize-first-letter-of-each-word&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Ucwords() function
&lt;/h2&gt;

&lt;p&gt;This function is used to convert/ capitalize the first character of each word in strings.  It is supported by all versions of PHP starting from the 4th version.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ucwords(string, delimiters)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ucwords function contains tow parameters, first parameter is “string” that is required and must be provided to get desired results. While the other one is an option and it is called delimiter, it will not affect the execution if you skip this parameter.&lt;/p&gt;

&lt;p&gt;Ucwords () on strings and arrays&lt;/p&gt;

&lt;p&gt;Here we will try this method on a string with a single parameter and with double parameters using a delimiter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;?php
echo ucwords("hello mr coder, enjoy coding php.");
echo '&amp;lt;/br&amp;gt;';

 //using delimiter 

 echo ucwords("hello| coder", '|');

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How does the ucwords () function work on arrays?
&lt;/h3&gt;

&lt;p&gt;This example will illustrate how can we use ucwords on arrays to capitalize on the first character of each word of string arrays.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$names =array(
  'john peter',
  'musa ahmad',
  'William parker',
  'yasir abbas',
  'brain larra'
);
foreach ($names as $name) {
print ucwords("{$name}\n").'&amp;lt;/br&amp;gt;'; }

//PRINTS:
John Peter
Musa Ahmad
William Parker
Yasir Abbas
Brain Larra 
?&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://kodlogs.com/blog/2599/php-capitalize-first-letter-of-each-word"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Mysqli_num_rows in PHP</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:31:56 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/mysqlinumrows-in-php-4j4k</link>
      <guid>https://dev.to/whataluckyguy/mysqlinumrows-in-php-4j4k</guid>
      <description>&lt;p&gt;PHP is an open-source programming language; it has built-in functions to communicate with the database and retrieve data. Mysqli_num_rows () function is used to check the number of rows in the query. This function is used after placing a query to check either database has any record or it is empty. This function has a return value. It returns the number of rows a table contains if the condition comes true and returns false for empty tables.&lt;/p&gt;

&lt;h1&gt;
  
  
  How to use Mysqli_num_rows ()?
&lt;/h1&gt;

&lt;p&gt;To use this function, you need to establish a database connection. this function returns true if the database has any record and returns false if the database has an empty recordset. This function is used to avoid errors in a web application because without checking the recordset if we perform further actions a program may have fatal errors and exceptions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax of mysqli_num_rows function&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&lt;br&gt;
mysqli_num_rows(result)&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
To check either if a database contains any rows, we need to pass a parameter or variable, variable contains the result returned by mysql_query. It checks a database and if there is any record it will return true and if there is nothing it will return false or empty.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;   let’s explore and evaluate this with the help of an example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php
$connection=mysqli_connect("localhost","username","password","database");
// Check connection
if (mysqli_connect_errno())
  {
  echo "database connection failed: " . mysqli_connect_error();
  }

$sql="SELECT Name,Lastname,Age,Class FROM students ORDER BY Lastname";

if ($result=mysqli_query($connection,$sql))
  {
  // Return the number of rows in result set
  $rowcount=mysqli_num_rows($result);//check if the database has any record
  printf("Result set has %d rows.\n",$rowcount);
  // Free result set
  mysqli_free_result($result);
  }

mysqli_close($connection);
?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/2538/mysqli_num_rows-in-php"&gt;https://kodlogs.com/blog/2538/mysqli_num_rows-in-php&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  code explained:
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;first, we made a connection to the database and checked if the connection is valid &lt;/li&gt;
&lt;li&gt;note that PHP is case sensitive for database records field names so always use the same as in  tables&lt;/li&gt;
&lt;li&gt;we used a variable $sql and assign a query to it &lt;/li&gt;
&lt;li&gt;we check if the query is valid and assigned it to the $result variable &lt;/li&gt;
&lt;li&gt;we used $rowscount and passed it the value of  mysqli_num_rows &lt;/li&gt;
&lt;li&gt;mysqli_num_rows will check the database and returns either try or false
&lt;a href="https://kodlogs.com/blog/2538/mysqli_num_rows-in-php"&gt;Read more in original post&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Fatal error Maximum execution time of 30 seconds exceeded in xampp.</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:24:38 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/fatal-error-maximum-execution-time-of-30-seconds-exceeded-in-xampp-5611</link>
      <guid>https://dev.to/whataluckyguy/fatal-error-maximum-execution-time-of-30-seconds-exceeded-in-xampp-5611</guid>
      <description>&lt;p&gt;This problem usually occurs when your PHP code takes a too long time to run. The time limit is very important because it helps to prevent the abuse of the server.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why maximum execution time error occur?
&lt;/h1&gt;

&lt;p&gt;This error mostly occurs in PHP Programming language. To protect the server from abuse there is the time limit to run the PHP script. The actual time is different according to hosting companies but mostly the maximum execution time is 30 to 60 seconds because this is enough time to run the PHP scripts.&lt;/p&gt;

&lt;p&gt;When the PHP script reaches the maximum execution time then the error occurs to maximum execution time exceeded.&lt;/p&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/215/fatal-error-maximum-execution-time-seconds-exceeded-xampp"&gt;https://kodlogs.com/blog/215/fatal-error-maximum-execution-time-seconds-exceeded-xampp&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Fixing maximum execution time exceeded error:
&lt;/h2&gt;

&lt;p&gt;Without changing anything in the system configuration we can fix this problem by just following the simple steps;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open file “php.ini” in the editor. This file is located under the directory “xampp/PHP/folder”.&lt;/li&gt;
&lt;li&gt;Find the “max_executuion_time” line. You can also find it by using ctrl+F.&lt;/li&gt;
&lt;li&gt;Modify it in the php.ini file
&lt;code&gt;
max_executuion_time = 120 ;           // This is the maximum execution time of script is in seconds
&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Modify the Excel Time Limit value in the file config.inc.php under the directory installdir/apps/phpmyadmin/htdocs/config.inc.php;
&lt;code&gt;
$cfg[‘ExecTimeLIMIt’] = 120;
&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Save and stop the Apache server in the xampp control panel.&lt;/li&gt;
&lt;li&gt;Restart the Apache server.
In this way, the maximum execution time of local server Xampp can be increased.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;br&gt;
To set the execution time-unlimited set the time limit 0 in both the above cases.&lt;br&gt;
&lt;a href="https://kodlogs.com/blog/215/fatal-error-maximum-execution-time-seconds-exceeded-xampp"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Remove first character from string C++</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:20:34 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/remove-first-character-from-string-c-379d</link>
      <guid>https://dev.to/whataluckyguy/remove-first-character-from-string-c-379d</guid>
      <description>&lt;p&gt;1.Declare a string&lt;br&gt;
2.Declare an integer variable&lt;br&gt;
3.Print String Statement&lt;br&gt;
4.Input from user string any&lt;br&gt;
5.integer variable call for string length&lt;br&gt;
6.return erase() function&lt;/p&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/769/remove-first-character-from-string-c"&gt;https://kodlogs.com/blog/769/remove-first-character-from-string-c&lt;/a&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include&amp;lt;iostream&amp;gt;
#include&amp;lt;string&amp;gt;
using namespace std;
int main(){
    string s;
    int n;
    cout&amp;lt;&amp;lt;"String = ";
    cin&amp;gt;&amp;gt;s;
    n=s.length();
    s.erase(s.begin());
    cout&amp;lt;&amp;lt;s;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://kodlogs.com/blog/769/remove-first-character-from-string-c"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>oop</category>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>How to convert integer to string in C++</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:16:43 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/how-to-convert-integer-to-string-in-c-44ic</link>
      <guid>https://dev.to/whataluckyguy/how-to-convert-integer-to-string-in-c-44ic</guid>
      <description>&lt;p&gt;Methods are given below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Do not use theitoa or functions itofas they are non-standard and therefore not portable.&lt;/li&gt;
&lt;li&gt;Use string streams
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; #include &amp;lt;sstream&amp;gt;  //include this to use string streams
 #include &amp;lt;string&amp;gt; 

int main()
{    
    int number = 1234;

    std::ostringstream ostr; //output string stream
    ostr &amp;lt;&amp;lt; number; //use the string stream just like cout,
    //except the stream prints not to stdout but to a string.

    std::string theNumberString = ostr.str(); //the str() function of the stream 
    //returns the string.

    //now  theNumberString is "1234"  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that you can use string streams also to convert floating point numbers to a string, and format the string as you wish, just like with cout&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;std::ostringstream ostr;
float f = 1.2;
int i = 3;
ostr &amp;lt;&amp;lt; f &amp;lt;&amp;lt; " + " i &amp;lt;&amp;lt; " = " &amp;lt;&amp;lt; f + i;   
std::string s = ostr.str();
//now s is "1.2 + 3 = 4.2" 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/2289/how-to-convert-integer-to-string-in-c-in-c-03"&gt;https://kodlogs.com/blog/2289/how-to-convert-integer-to-string-in-c-in-c-03&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;You can use stream manipulators like std::endl, std::hex and functions std::setw(), std::setprecision() etc. with string streams just like with cout&lt;/p&gt;

&lt;p&gt;Do not confuse std::ostringstream with std::ostrstream. The latter is obsolete&lt;/p&gt;

&lt;p&gt;Use boost lexical casting. If you are not familiar with boost, it is a good idea to start with a small library like this lexical_cast. You can download and install boost and its documentation here . Although boost is not part of the C ++ standard, many boost libraries are eventually standardized, and boost is widely regarded as one of the best C ++ libraries.&lt;/p&gt;

&lt;p&gt;Lexical casting uses streams at the bottom, so this is basically the same as the previous one, only less verbose.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;boost/lexical_cast.hpp&amp;gt;
#include &amp;lt;string&amp;gt;

int main()
{
   float f = 1.2;
   int i = 42;
   std::string sf = boost::lexical_cast&amp;lt;std::string&amp;gt;(f); //sf is "1.2"
   std::string si = boost::lexical_cast&amp;lt;std::string&amp;gt;(i); //sf is "42"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to convert string to number in C ++ 03:(Method 2):
&lt;/h3&gt;

&lt;p&gt;The easiest option, inherited from C, is functions atoi (for integers (alphabet to integer)) and atof (for floating point values ​​(alphabet to float)). These functions take a C-style ( const char *) string as an argument , and therefore may not be considered good C ++ practice to use them . cplusplus.com has easy-to-understand documentation for both atoi and atof, including how they behave in the event of bad input. However, the reference contains the error that, according to the standard, if the input number is too large to fit into the target type, the behavior is undefined.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;cstdlib&amp;gt; //the standard C library header
#include &amp;lt;string&amp;gt;
int main()
{
    std::string si = "12";
    std::string sf = "1.2";
    int i = atoi(si.c_str()); //the c_str() function "converts" 
    double f = atof(sf.c_str()); //std::string to const char*
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use string streams (this time input string stream, istringstream). Again, istringstream is used in the same way as cin. Again, do not be confused istringstream with istrstream. The latter is already obsolete.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;sstream&amp;gt;
#include &amp;lt;string&amp;gt;
int main()
{
   std::string inputString = "1234 12.3 44";
   std::istringstream istr(inputString);
   int i1, i2;
   float f;
   istr &amp;gt;&amp;gt; i1 &amp;gt;&amp;gt; f &amp;gt;&amp;gt; i2;
   //i1 is 1234, f is 12.3, i2 is 44  
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use boost lexical casting.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#include &amp;lt;boost/lexical_cast.hpp&amp;gt;
#include &amp;lt;string&amp;gt;

int main()
{
   std::string sf = "42.2"; 
   std::string si = "42";
   float f = boost::lexical_cast&amp;lt;float&amp;gt;(sf); //f is 42.2
   int i = boost::lexical_cast&amp;lt;int&amp;gt;(si);  //i is 42
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case of incorrect input, lexical_cast throws an exception of the type boost::bad_lexical_cast&lt;br&gt;
&lt;a href="https://kodlogs.com/blog/2289/how-to-convert-integer-to-string-in-c-in-c-03"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>computerscience</category>
      <category>oop</category>
      <category>programming</category>
    </item>
    <item>
      <title>Control reaches end of non-void function C++</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 17:11:57 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/control-reaches-end-of-non-void-function-c-290j</link>
      <guid>https://dev.to/whataluckyguy/control-reaches-end-of-non-void-function-c-290j</guid>
      <description>&lt;p&gt;The error &lt;strong&gt;‘control reaches end of non-void function C++’&lt;/strong&gt; occurs in compiling a code, due to misunderstanding of the flow of control in our algorithm. To overcome this error or the representation of the code is to flow the pseudocode. This warning is similar to the warning described in return with no value. If control reaches the end of a function and no return is encountered, GCC compiler assumes a return with no return value. However, for this, the function requires a return value. At the end of the function, add a return statement that returns a suitable return value, even if control never reaches there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int main(void)
{
    my_strcpy(strB, strA);
    puts(strB);
    return 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This problem comes from a misunderstanding of the flow of control in the algorithm. Here's a representation of that control flow in pseudocode:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (outer-condition-1)
    if (inner-condition-1)
        return 1
else if (outer-condition-2)
    if (inner-condition-2)
        return -1
else
    return 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An else block is only ever related to one if...elseif...else construct at a time, so the last else block is attached only to the outer if conditions and not to the inner if conditions. If an outer condition evaluates to true and its inner condition evaluates to false, the else block will not be executed at all. This means the function will never encounter an explicit return statement, which is what the compiler doesn't like; every function must always return something, no matter what input it receives.&lt;/p&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/32/control-reaches-end-of-non-void-function-c"&gt;https://kodlogs.com/blog/32/control-reaches-end-of-non-void-function-c&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;There are a few ways to fix this. The most direct solution is to add a return statement at the end of the function, outside of the conditional statements, but that's a bit messy, it can hide problems that would otherwise throw errors, making it a bit harder to find bugs.&lt;/p&gt;

&lt;p&gt;Another way is to flatten your nested conditions, so that the pseudocode looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (outer-condition-1 and inner-condition-1)
    return 1
else if (outer-condition-2 and inner-condition-2)
    return -1
else
    return 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That might be appropriate if you're sure your program is working as intended with the current setup. But if you need something unique to happen when an outer condition is satisfied and an inner condition is not satisfied, you need to keep the nested structure but deal directly with every possible outcome.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (outer-condition-1)
    if (inner-condition-1)
        return 1
    else
        return 2
else if (outer-condition-2)
    if (inner-condition-2)
        return -1
    else
        return -2
else
    return 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In either case, once the program reaches the first if statement, &lt;strong&gt;every path available to it will result in an explicit return statement, thus avoiding the control my reach end of non-void function.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A related concept is "single entry, single exit" (SESE), which would demand that your function return a value only once at the end, rather than using the "early return" statements inside the conditional logic. This usually means defining an extra variable to hold the value that will be returned; for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;declare int r
if (condition-1)
    r = 1
else if (condition-2)
    r = -1
else
    r = 0
return r
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://kodlogs.com/blog/32/control-reaches-end-of-non-void-function-c"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cpp</category>
      <category>programming</category>
      <category>oop</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>The system cannot find the file specified java</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 11:00:25 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/the-system-cannot-find-the-file-specified-java-2icp</link>
      <guid>https://dev.to/whataluckyguy/the-system-cannot-find-the-file-specified-java-2icp</guid>
      <description>&lt;p&gt;In this article, we will discuss a common issue.When you face the following error: "java.io.FileNotFoundException: the system cannot find the file specified" and error similar to below is visible in logs:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Exception in thread "main" java.io.FileNotFoundException: Report.PDF (The system cannot find the file specified)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;at java.io.FileInputStream.open(Native Method)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;at java.io.FileInputStream.(Unknown Source)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;at java.util.Scanner.(Unknown Source)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The issue as the error suggests is that system is not able to find the file; you need to provide the correct path for it. For example, a file can be either read on a relative path like&lt;br&gt;
&lt;strong&gt;&lt;a href="/APP_NAME/uploads/Report.PDF"&gt;Report&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here APP_NAME is the name of your application that contains uploads directory which contains Report.PDF. This will open a file in the browser's new tab as a PDF document.&lt;/p&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/2129/the-system-cannot-find-the-file-specified-java"&gt;https://kodlogs.com/blog/2129/the-system-cannot-find-the-file-specified-java&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Please note its not a good idea to store files inside the application, as once the application is reinstalled previous files are gone. Hence you can store files outside the application and files can be rendered from there. You can store the name of the file in a database like Report.PDF and can set upload directory in System property i.e. java.io.tmpdir=D://APP_NAME/uploads/&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For example, you can create the following link to download file dynamically using JSP:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="download.jsp?fileName=Report.PDF"&gt;Report&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;download.jsp should have the following code, once the above link is clicked it will be displayed as an attachment box to the end-user which he/she can either Save or Open.&lt;/p&gt;

&lt;p&gt;**1. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;%&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;String fileName = request.getParameter("fileName");&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;response.setContentType("application/octet-stream");&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;response.setHeader("Content-Disposition", "attachment;filename="+extractFileName(fileName));&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;try {    &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;// You can set java.io.tmpdir in System property as "D://APP_NAME/uploads/" as its not a good idea to store files inside the application, as once the application is reinstalled previous files are gone. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;String filePath= System.getProperty("java.io.tmpdir");&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(filePath==null || filePath.isEmpty()){
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;%&amp;gt; Error: Please set java.io.tmpdir. &amp;lt;%&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;}else{    &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;File file = new File(filePath+fileName); //"D://APP_NAME/uploads/Report.pdf"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;FileInputStream fileIn = new FileInputStream(file);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ServletOutputStream output = response.getOutputStream();&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;int len = fileIn.available();&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;byte[] outputByte = new byte[len];&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;//copy binary contect to output stream&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while(fileIn.read(outputByte, 0, len) != -1) {
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;output.write(outputByte, 0, len);&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;}    &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;response.setContentLength((int) file.length());&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;fileIn.close();&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;output.flush();&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;output.close();&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;} catch (Exception e) {&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;%&amp;gt; Exception ::: &amp;lt;%= e.getMessage() %&amp;gt; &amp;lt;%&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;} %&amp;gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&amp;lt;%!&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;public  String extractFileName( String filePathName ){&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if ( filePathName == null )  return null;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;int slashPos = filePathName.lastIndexOf( '\' );&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if ( slashPos == -1 ) slashPos = filePathName.lastIndexOf( '/' );
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return filePathName.substring( slashPos &amp;gt; 0 ? slashPos + 1 : 0 );
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;}&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;%&amp;gt;**&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://kodlogs.com/blog/2129/the-system-cannot-find-the-file-specified-java"&gt;Read more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>How to remove whitespaces from a string in java</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 10:56:11 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/how-to-remove-whitespaces-from-a-string-in-java-599a</link>
      <guid>https://dev.to/whataluckyguy/how-to-remove-whitespaces-from-a-string-in-java-599a</guid>
      <description>&lt;p&gt;In this article, we will learn &lt;strong&gt;how to remove spaces from a string in java&lt;/strong&gt;&lt;br&gt;
In thisblog, we will learn how to remove the whitespace from a string in java. One method uses a brand built-in method that will be useful when you are developing applications and other methods do not use the built-in methods that will help to interview you. Because, in the interview, the interviewer always asks to not use the built-in method while testing your coding skills&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Remove White Spaces Of String in Java Using Built-In Methods?
&lt;/h3&gt;

&lt;p&gt;In the first method, we use the method replaceAll () of the String class to remove all whitespace (including tabs as well) from the string. It is one of the easiest ways to remove the spaces from the string in java. replaceAll () method takes two parameters. One of them is the string to be replaced and another one is the string that will be replaced with. We passed the string "\ s +" to be replaced with an empty string "". This method removes spaces at the end, the space at the beginning and a space between the words.&lt;/p&gt;

&lt;p&gt;1&lt;br&gt;
2&lt;br&gt;
3&lt;br&gt;
4&lt;br&gt;
5&lt;br&gt;
6&lt;br&gt;
7&lt;br&gt;
8&lt;br&gt;
9&lt;br&gt;
10&lt;br&gt;
11&lt;br&gt;
12&lt;br&gt;
13&lt;br&gt;
14&lt;br&gt;
15&lt;br&gt;
16&lt;br&gt;
17&lt;br&gt;
18&lt;br&gt;
19&lt;br&gt;
20&lt;br&gt;
21&lt;/p&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/2204/how-to-remove-spaces-from-a-string-in-java"&gt;https://kodlogs.com/blog/2204/how-to-remove-spaces-from-a-string-in-java&lt;/a&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Program
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java.util.Scanner import;

Public class RemoveWhiteSpaces
{
    public static void main (String [] args)
    {
        Scanner sc = new Scanner (System.in);

        System.out.println ( "Enter input string to be cleaned of the white space ...!");

        String inputString = sc.nextLine ();

        String stringWithoutSpaces = inputString.replaceAll ( " s +", "");

        System.out.println ( "Input String:" + inputString);

        System.out.println ( "String Input Without Spaces:" + stringWithoutSpaces);

        sc.close ();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  output:
&lt;/h3&gt;

&lt;p&gt;Enter input string to be cleaned of the white space ...!&lt;br&gt;
One space TwoSpaces ThreeSpaces FourSpaces Tab End&lt;br&gt;
String input: one space TwoSpaces ThreeSpaces FourSpaces Tab End&lt;br&gt;
Put String Without Spaces: OneSpaceTwoSpacesThreeSpacesFourSpacesTabEnd&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"\ s +" Vs "\ s": Both of these strings, when passing to replaceAll () method, produce the same results with similar performance. But, when the number of consecutive rising space, "\ s +" is a little faster than the "\ s". Because, replacing some space set in a row&lt;br&gt;
with the replacement string at a time rather than replacing one by one.&lt;br&gt;
trim () method trims string given mis eliminate white space at the beginning and at the end of the string, not the words.&lt;br&gt;
&lt;a href="https://kodlogs.com/blog/2204/how-to-remove-spaces-from-a-string-in-java"&gt;Find more in original post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>The document could not be saved. A number is out of range.</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 10:49:25 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/the-document-could-not-be-saved-a-number-is-out-of-range-1fl7</link>
      <guid>https://dev.to/whataluckyguy/the-document-could-not-be-saved-a-number-is-out-of-range-1fl7</guid>
      <description>&lt;p&gt;When the user tries to view a PDF or delete a page from a PDF, then you see an error message;&lt;br&gt;
&lt;code&gt;&lt;br&gt;
“A number is out of range.”&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
A user can also get the same error when you try to perform other actions on the PDF, such as combining it with another PDF or inserting a new page.&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution:
&lt;/h1&gt;

&lt;p&gt;Export the PDF as a PostScript file and then convert it into a PDF using Distiller. The “A number is out of range” error occurs when Acrobat finds some problem with the underlying structure of the PDF file. The best solution is to get a new PDF from the owner. If you can’t get one, then follow the below steps to resolve the problem.&lt;/p&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/692/the-document-could-not-be-saved-a-number-is-out-of-range"&gt;https://kodlogs.com/blog/692/the-document-could-not-be-saved-a-number-is-out-of-range&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Steps to follow:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open the PDF in Acrobat.&lt;/li&gt;
&lt;li&gt;Choose File -&amp;gt; Export To -&amp;gt; PostScript.&lt;/li&gt;
&lt;li&gt;In the Save As PDF dialog box, enter a different name for the file and then click on the Save button.&lt;/li&gt;
&lt;li&gt;Go to the folder where you saved the PostScript. Right-click on the file and choose Open with Adobe Acrobat Distiller. Acrobat Distiller converts the PostScript file into PDF file. The PDF file now saved in the same folder.&lt;/li&gt;
&lt;li&gt;Open the PDF file in Acrobat. Now you can try to view the pages or delete, insert, or add a page in the PDF.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://kodlogs.com/blog/692/the-document-could-not-be-saved-a-number-is-out-of-range"&gt;Find more in original blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>computerscience</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Python sort list of tuples by first element</title>
      <dc:creator>Lalit Kumar</dc:creator>
      <pubDate>Sun, 20 Dec 2020 08:48:51 +0000</pubDate>
      <link>https://dev.to/whataluckyguy/python-sort-list-of-tuples-by-first-element-d89</link>
      <guid>https://dev.to/whataluckyguy/python-sort-list-of-tuples-by-first-element-d89</guid>
      <description>&lt;p&gt;In this post i will tell you about “python sort list of tuples by first element” which is easy and need just basic knowledge. A tuple is defined as a collection that is ordered and unchangeable.&lt;/p&gt;

&lt;h1&gt;
  
  
  DEFINITION ABOUT TUPLE
&lt;/h1&gt;

&lt;p&gt;In Python programming language, tuples are written within round brackets.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tuple is defined as a collection that is ordered nd’ unchangeable. It allows doing duplicate members.&lt;/li&gt;
&lt;li&gt;Example TUPLE.&lt;/li&gt;
&lt;li&gt;thistuple = ("sun", "moon", "stars")
print(thistuple)&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;title: "originally posted here 👇"&lt;/p&gt;

&lt;h2&gt;
  
  
  canonical_url: &lt;a href="https://kodlogs.com/blog/2600/python-sort-list-of-tuples-by-first-element"&gt;https://kodlogs.com/blog/2600/python-sort-list-of-tuples-by-first-element&lt;/a&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Python sort lists of tuples by first element...
&lt;/h2&gt;

&lt;p&gt;If a list of tuples are given, write a Python program to sort the tuples by first element of every tuple.&lt;/p&gt;

&lt;p&gt;Access&lt;/p&gt;

&lt;p&gt;first element of each tuple using the nested loops. &lt;/p&gt;

&lt;p&gt;Reverse : To sort these in ascending order we could have just Python.&lt;/p&gt;

&lt;p&gt;Remove tuple having duplicate first value from given list of  Sorting that list of numbers / characters is easy. &lt;/p&gt;

&lt;p&gt;We can use sort() method /  sorted() built-in function. In this , we want to sort a list of tuples by first value in the tuple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example-&lt;/strong&gt; Let’s consider a tuple list having actor’s charater in a movie and his real name. [(Robert Downey Jr, "Ironman"), (Chris Evans, "Captain America")]&lt;/p&gt;

&lt;h2&gt;
  
  
  Method of Executing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Method:&lt;/strong&gt; Using sort() method&lt;/p&gt;

&lt;p&gt;When we sort via this method the actual content of the tuple is changed, just like the previous method, the in-place method of sort is executed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Python programming code to sort a list of tuple by the first element using sort()  

# Functions to sort the list by first element of tuple 

def Sort_Tuple(tup):  

    # reverse = None (get sorted in Ascending order)  
    # key is a set to sort using second element of  
    # sublist lambda is used  
    tup.sort(key = lambda x: x[1])  
    return tup  

# Driver Code  
tup = [('saket', 10), ('tony', 5), ('steve', 20), ('bahubali', 15)]  

# print the sorted list of tuples 
print(Sort_Tuple(tup))  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;

&lt;p&gt;[('tony', 5), ('saket', 10), ('bahubali', 15), ('steve', 20)]&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>computerscience</category>
    </item>
  </channel>
</rss>
