salazar's Profile User Rating: -----

Reputation: 102 Stalwart
Group:
Active Members
Active Posts:
593 (0.74 per day)
Joined:
26-June 13
Profile Views:
4,024
Last Active:
User is offline Aug 19 2015 10:38 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
Intel
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   salazar has not set their status

Posts I've Made

  1. In Topic: Need help with a program.

    Posted 19 Aug 2015

    View PostA7r1a5, on 19 August 2015 - 07:48 PM, said:

    View PostAnarion, on 19 August 2015 - 06:16 PM, said:

    Use proper indentation to make your code more readable. It can also help you find out some mistakes easier.

    Now towards the error, take a closer look at the loop(s) you have:
    for (y = 0; y < n; y++)
    {
        if (s[x] != ' ')
        {
            printf("%c", s[x]);
            x++;
        }
        do
        {
            x++;
        }
        while (s[x] != ' ');
        if (s[x] == ' ')
        {
            x++;
        }
        if (x == n)
        {   
            break;   
        }
    }
    

    In the for loop, you make sure you don't get out of the bound of the string. That's good. But I don't understand why you have both x and y? You are using an extra variable here. Stick either to x or y.
    Also, inside this loop you have an unsafe loop:
    do
    {
        x++;
    } while (s[x] != ' ');
    

    Is there any guarantee that this loop doesn't get out of the higher bound for the string? I don't see any checking done for this part. Could x get higher than n-1 which is the higher bound of the string?

    If you want to fix such issues, first you should come up with a clean and clear description of what and how you want to do. Use this as a guide for writing the code.


    I don't thi k you know what you're talking about sir.


    Maybe you can be more specific instead of stating that he doesn't understand. I'm sure he knows what he's talking about. His reputation speaks for itself.
  2. In Topic: Java Help

    Posted 19 Aug 2015

    When you use the '>' operator the two operands must be of the same type. Here, you have a the var, age which is a string and you 50, a number.

    To fix, you need to convert the age to a string first. This can easily be done using
    if (Integer.parseInt(age) < 50)
    
    

    But remember for future reference: types must be the same.
  3. In Topic: Dynamically resize JFrame

    Posted 15 Aug 2015

    Have you tried using setSize ()?
  4. In Topic: HTML CANVAS TO IMAGE

    Posted 15 Aug 2015

    Hmm I wonder how a canvas gets saved to an image. Sounds cool.
  5. In Topic: Split and merge of file

    Posted 15 Aug 2015

    Also, get into the habit of writing functions. You main is a function but you can write your own custom functions. It will make it alot easier to read and fix bugs.

    Also, what you are doing is called 'hard coding'. That is you have specific values that don't change as the input to your program. That's just a one and done. So your correct to want to change it as you mentioned. Following gooses's advice should help.

My Information

Member Title:
D.I.C Addict
Age:
23 years old
Birthday:
November 12, 1991
Gender:
Interests:
Software Development
Years Programming:
5
Programming Languages:
Specialty: C/C++, Java
Others: Php, Bash, Perl, Prolog, Sql, UML, Javascipt, Html/CSS

Contact Information

E-mail:
Click here to e-mail me

Friends

salazar hasn't added any friends yet.

Comments

Page 1 of 1
  1. Photo

    JA94 Icon

    04 Nov 2013 - 11:36
    hey,
    how do you pm someone on this site?
  2. Photo

    salazar Icon

    03 Sep 2013 - 18:27
    Hello me.
Page 1 of 1