Thread: space between names

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    1

    Question space between names

    I'm new to programming in general. I've been working in this problem for a bit now. it tells me that "If there is no middle initial then there should only be one (1) space separating the first name and the last name"
    my solution is this but unfortunately if there's no middle name the space still showing between the first and last name.

    printf(" %s %s %s\n", contacts->name.firstName, contacts->name.middleInitial, contacts->name.lastName);

    can any of you guy help me with this? I have no idea where to start.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Use this when there is no middle initial.
    printf("%s %s\n", contacts->name.firstName, contacts->name.lastName);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Look up strlen
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Names
    By BretFlorida in forum C Programming
    Replies: 1
    Last Post: 04-15-2013, 05:16 PM
  2. NUMA Virtual Adress Space / Physical Adress Space
    By NUMA Orly in forum Windows Programming
    Replies: 0
    Last Post: 03-14-2011, 03:19 AM
  3. Help with Names
    By big146 in forum C++ Programming
    Replies: 13
    Last Post: 06-07-2004, 01:26 PM
  4. Old names?
    By Fordy in forum A Brief History of Cprogramming.com
    Replies: 80
    Last Post: 10-28-2001, 07:39 PM
  5. former names...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 08-17-2001, 05:03 AM

Tags for this Thread