Help needed making C program.

Discussion in 'C' started by naurozbaloch, Jan 5, 2010.

  1. naurozbaloch

    naurozbaloch New Member

    Joined:
    Jan 5, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi Folks,
    I need to make a C program in which ,
    1)alphabets are assigned some values. e.g a=1,b=2,c=3,d=65 and so on.
    2) computer takes input of a word. e.g the input word is "nauroz" given by user.
    3)program prints the numbers which have been assigned to different alphabets and prints the number for word "nauroz".

    plzz help needed. I am a newbie.
     
  2. vignesh1988i

    vignesh1988i Banned

    Joined:
    Sep 19, 2009
    Messages:
    72
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Chennai
    pl. expalin the 2nd point properly......... :smug::thinking:
     
  3. vignesh1988i

    vignesh1988i Banned

    Joined:
    Sep 19, 2009
    Messages:
    72
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Chennai
    sorry , pl. explain the 1st point... not 2nd point... :thinking:
     
  4. naurozbaloch

    naurozbaloch New Member

    Joined:
    Jan 5, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Thanks alot for your contributation . I have solved that problem.but not i want output of that program to be transfered on notepad , i don't know how to do this? could anyone plz help?

    Thanks ,
    Nauroz Baloch
     
  5. racergun80

    racergun80 New Member

    Joined:
    Jan 7, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    hi,

    Open a file in write mode and with the extension .txt
    then write to it.

    You'll find lots of examples for writing to the file on the internet.

    All the best
     
  6. Deadly Ghos7

    Deadly Ghos7 New Member

    Joined:
    Dec 19, 2009
    Messages:
    55
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    Student
    Location:
    Earth
    Home Page:
    http://www.techgaun.com
    do either through cmd redirection using > operator like yourprogram.exe>file.txt or using the file handling concept of c
    Code:
    FILE *fp;
    
    fp = fopen("file.txt","ab+");
    //this opens file handling mode
    
    Now use various file output functions available in C to write what you want in to the text file.
     
  7. naurozbaloch

    naurozbaloch New Member

    Joined:
    Jan 5, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    what is cmd redirection?
    i tried the above code compiler warmed me that fp is assigned a value that is never used?
    what to do with this. I am new to programming.
    Thanks all for contribution.
     
  8. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    http://mvenkatapathy.wordpress.com
    The above code given by "DeadlyGhos7" tells you how to open a file. But you have to finish the code by referring to other examples of FILE programming in C.

    Command redirection will redirect the output of a program(which will be printed on screen) to any other file that we want.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice