noob question just cant remember how

This is a discussion on noob question just cant remember how within the C Programming forums, part of the General Programming Boards category; i need a program that can scanf a word and printf it again but it should only be possible to ...

  1. #1
    Registered User
    Join Date
    Apr 2005
    Posts
    19

    noob question just cant remember how

    i need a program that can scanf a word and printf it again but it should only be possible to write letters in the scanf

    if you write numbers or so it should printf a error or something

  2. #2
    Registered User mitakeet's Avatar
    Join Date
    Jun 2005
    Location
    Maryland, USA
    Posts
    212
    So write one! If you have questions about code you have already written, post back here (be sure to enclose your code in "code" tags!).

    Free code: http://sol-biotech.com/code/.

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw

  3. #3
    Registered User
    Join Date
    Apr 2005
    Posts
    19
    Quote Originally Posted by mitakeet
    So write one! If you have questions about code you have already written, post back here (be sure to enclose your code in "code" tags!).
    did you read the title ?

  4. #4
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    Your compiler come with helpfiles?
    Did google puke on "use of scanf"?

    Dont expect code to be given, your question looks to me like a very thinly veiled "I cant do my own homework so someone do it for me" type question. Post your code we will willingly help fix it up. Come begging and nobody will take any notice.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  5. #5
    Registered User
    Join Date
    Apr 2005
    Posts
    19
    fair...

    Code:
    #include<stdio.h>
    
    int main(void)
    {
    	
    	char c[255];
    	
    	puts("skriv noget her ffs\n");
    	gets(c);
    	puts(c);
    	return 0;
    }
    now i only need a way to remove everything but a-z and A-Z

  6. #6
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    For starters consult our FAQ for reasons not to use gets() and follow the advice there to fix that problem. For the elimination of all but alphabetical characters you can use the functions in ctype.h such as isalpha() and isspace() etc. look them up in your helpfiles and have a go for yourself. Post your efforts and we'll help further should it be needed.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  7. #7
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    I would also take a look at sscanf(). This is usually the recommended way by the C guys.
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. quick noob question
    By thanatos1 in forum C# Programming
    Replies: 2
    Last Post: 06-17-2009, 09:28 PM
  2. another noob question
    By clb2003 in forum C Programming
    Replies: 4
    Last Post: 02-12-2009, 01:28 PM
  3. Noob printf question
    By lolguy in forum C Programming
    Replies: 3
    Last Post: 12-14-2008, 08:08 PM
  4. Noob question (redeclaring a array)
    By Demon.killer in forum C Programming
    Replies: 8
    Last Post: 10-21-2006, 01:06 PM
  5. Noob Question
    By bumfluff in forum C++ Programming
    Replies: 4
    Last Post: 11-06-2005, 04:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21