i want to get the integer value of ith character in the string, this is my program please tell me mistakes.

#include <stdio.h>
#include <cs50.h>
#include <string.h>

int main (void)

    string s = GetString();
    int n=strlen(s);
    for (int i=0;i<n;i++)
    int a = s [i];


Your program almost does what you want. You need to review the class material on for loops, particularly the use of curly braces to create a block of code to be executed by the for loop.

You might also want to look at formatting characters for the printf statement, including '\n' and maybe even add in a space or two.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Problem solved on the guidelines given by you.Thanks a lot. – Ahmed Raza Aug 8 '16 at 8:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .