question about string

This is a discussion on question about string within the C Programming forums, part of the General Programming Boards category; if i set the char array as a 2d array, how can i get the string from the user i ...

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    10

    question about string

    if i set the char array as a 2d array, how can i get the string from the user
    i have tried to use 'gets', but when i compiled it, there is syntax error..

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    10
    i wanna ask what is stdin??

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    10
    also, if i dont use fgets, can i have another way to get the string?

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>also, if i dont use fgets, can i have another way to get the string?<<
    You can also use getchar() to read one byte at a time, but why bother when fgets() does a fine job.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    102
    I dont know why salem said like this:
    >If you're thinking of using gets(), then forget it
    I tried something like this:
    Code:
    main()
    {
    	char strings[10][20];
    	int i;
    	for(i=0;i<=9;i++)
    	{
    		gets(strings[i]);//a point to be noted
                                                               is entering char <= 20
    	}
    	for(i=0;i<=9;i++)
    	{
    		puts(strings[i]);
    	}
    }
    Saravanan.T.S.
    Beginner.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by saravanan_ts
    I dont know why salem said like this:
    >If you're thinking of using gets(), then forget it
    I tried something like this:
    You don't know because you obviously didn't read the FAQ link that Salem provided. Honeslty though, I don't know why I bother providing the same link. You didn't read it the fist time, why should now be any different?

    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    102
    Thanks quazah
    Saravanan.T.S.
    Beginner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 05:05 AM
  2. Reusing a string pointer question
    By chiefmonkey in forum C++ Programming
    Replies: 3
    Last Post: 05-06-2009, 05:53 PM
  3. Program using classes - keeps crashing
    By webren in forum C++ Programming
    Replies: 4
    Last Post: 09-16-2005, 04:58 PM
  4. String array question
    By gogo in forum C++ Programming
    Replies: 6
    Last Post: 12-08-2001, 06:44 PM

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