GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 18-Nov-2006, 11:31
nooranshasi nooranshasi is offline
New Member
 
Join Date: Nov 2006
Posts: 10
nooranshasi is on a distinguished road

strings?!!!! :S


i have this question i've been trying to work out:

strings in C are really arrays containing many elements of tpye char. the following program shows how to declare and use C strings.

CPP / C++ / C Code:
#include <stdio.h>
int main()
{
     char string[100]; /* declares a string of 100 characters*/
     int i;
     printf:("enter a string: ");
     scanf("%s", string);
     printf("string = %s\n", string);
     i=0;
     while (string [ i ] != '\0') {
          printf("string[ %d ] = %c\n", i, string[ i ] );
		  i++;
	 }
     return0;

use this program as a starting point and convert the program to using strings.


please i neeeeed help in this program im a new user here and a new programmer!
Last edited by LuciWiz : 18-Nov-2006 at 13:59. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
  #2  
Old 18-Nov-2006, 11:54
mathematician mathematician is offline
Member
 
Join Date: Nov 2006
Location: Shrewsbury Uk
Posts: 131
mathematician will become famous soon enough

Re: strings?!!!! :S


Not sure what you mean. You obviously know how to input a string, and print it out again, so what's the problem? (Actually, strings are really arrays in all languages; it's only made more explicit in C.)
  #3  
Old 18-Nov-2006, 12:04
nooranshasi nooranshasi is offline
New Member
 
Join Date: Nov 2006
Posts: 10
nooranshasi is on a distinguished road

Re: strings?!!!! :S


i dont know but i got a homework and this is what it says.. !!! the program is part of the question its not something i wrote
  #4  
Old 18-Nov-2006, 12:30
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,258
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all

Re: strings?!!!! :S


Quote:
Originally Posted by nooranshasi
use this program as a starting point and convert the program to using strings.
You posted a program that uses strings. How would you like to convert it into using strings?

Also, please read the Guidelines.
__________________

Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough.
-- Pearl Williams
  #5  
Old 18-Nov-2006, 12:37
mathematician mathematician is offline
Member
 
Join Date: Nov 2006
Location: Shrewsbury Uk
Posts: 131
mathematician will become famous soon enough

Re: strings?!!!! :S


Are "this program", which is the example, and "the program", which you're supposed to convert, two different programs? It doesn't seem to make sense otherwise.
  #6  
Old 18-Nov-2006, 12:59
nooranshasi nooranshasi is offline
New Member
 
Join Date: Nov 2006
Posts: 10
nooranshasi is on a distinguished road

Re: strings?!!!! :S


yeahhhh the program is the progam i have to convert
  #7  
Old 18-Nov-2006, 13:16
nooranshasi nooranshasi is offline
New Member
 
Join Date: Nov 2006
Posts: 10
nooranshasi is on a distinguished road

Re: strings?!!!! :S


the question is ::
use this program as a starting point and convert the question to using strings!



i dont know what the hell does it mean!
  #8  
Old 18-Nov-2006, 13:48
mathematician mathematician is offline
Member
 
Join Date: Nov 2006
Location: Shrewsbury Uk
Posts: 131
mathematician will become famous soon enough

Re: strings?!!!! :S


Well is it a reference back to an earlier question about using strings? If not, you can tell your professor that it was not only you, but two programmers on this web site who were baffled by what the question was supposed to mean.
  #9  
Old 18-Nov-2006, 13:52
nooranshasi nooranshasi is offline
New Member
 
Join Date: Nov 2006
Posts: 10
nooranshasi is on a distinguished road

Re: strings?!!!! :S


yeah there were these questions:

1)to develop a program that will input an arbitary series of uppercase english letters and convert them to lowercase letters..using a dot character "." to end the input. the conversion will be done each time a character is input. if lowercase characters are entered then then the program should print "illegal input character".

2) using the progam above as a starting point, define a new function to perform the conversion. the function is declared using the following prototype:
void convertToLower(char inputCharacter);

3) using the above program as a starting point.. seperate the printing of the output character from the conversion. the function definition and prototype should be converted to the following:
char ConvertToLower(char inputCharacter);
the modification should simply perform the conversition and return the new character. if the conversion did not take place the function should return the minus character.

4) using the above program as a starting point. develop a program that will display this menu on the screen:
1 to convert key from uppercase to lowercase
2 to convert lowercase to uppercase
conversion key:
  #10  
Old 18-Nov-2006, 13:56
nooranshasi nooranshasi is offline
New Member
 
Join Date: Nov 2006
Posts: 10
nooranshasi is on a distinguished road

Re: strings?!!!! :S


and question was this question:
strings in C are really arrays containing many elements of tpye char. the following program shows how to declare and use C strings.[/b]

CPP / C++ / C Code:
#include <stdio.h>
int main()
{
     char string[100]; [i]/* declares a string of 100 characters*/[/i]
     int i;
     printf:"enter a string: ");
     scanf("%s", string)
     printf*"string = %s\n", string);
     i=0;
     while (string [ i ] != '\0') {
          printf("string[ %d ] = %c\n", i, string[ i ] );
      }
     return0;
}

use this program as a starting point and convert question 5 to using strings.
Last edited by LuciWiz : 18-Nov-2006 at 14:00. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
 
 

Recent GIDBlogPython ebook by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you read strings from a file...? jpxtreme C Programming Language 6 28-Sep-2006 10:55
Strings tripping me up once more Elsydeon C++ Forum 5 04-Dec-2005 18:41
need help - questions about strings Benayoun C Programming Language 6 24-Jan-2005 03:15
C++ style strings and STL dexter C++ Forum 14 04-Jan-2005 08:46

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 14:49.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.