Thread: Helps with strings

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    13

    Angry Helps with strings

    This is my first time working with strings so im not really sure what I am doing. My assignment is to write and test a function, deblank, that takes a sting output and a sting input argument and returns a copy of the input argument with a blanks removed.

    I started out by just trying to see if I can create a string and print it out. But I am having problems even doing that. I can build it but when I try to debug it I get an error in the middle of debugging it. Any suggestions will be appreciated.

    Code:
    // Strings.cpp : Defines the entry point for the console application.
    //
    
    //    distance.cpp
    
    #include<stdio.h>
    #include<stdafx.h>
    #include"conio.h"
    #include"string.h"
    
    int main()
    {char string_one[11] = "string_one";
    
    sprintf("Topic: %s/n", string_one);
    
    
    getch();
    return(0);
    }

  2. #2
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Chappell Hill, Texas
    Posts
    2,332
    Remove "sprintf" and just use "printf" for that particular use.

    And, the escape character is backslash, not forward slash, but you would have seen that soon enough.
    Mainframe assembler programmer by trade. C coder when I can.

  3. #3
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Why new learners don't do proper indentation??
    I get really messed up at the simplest code, if, it's not properly indented!

  4. #4
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    Quote Originally Posted by manav View Post
    Why new learners don't do proper indentation??
    I get really messed up at the simplest code, if, it's not properly indented!
    The clue is in the third word...

    QuantumPete
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Problems with strings as key in STL maps
    By all_names_taken in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:34 AM
  4. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM