Thread: help with char array.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    9
    I did initialize i. Just to be safe, I even set it to zero just now after your post, still got the error.

    Code:
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    	
    	char  num[]= "9781552859544";
    	int i=0;
    	for (; i<12; i++)
    	{
    		
    		
    		printf("%s", num[i]);
    		
    		
    	}
    	return 0;
    }

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Quote Originally Posted by sup_stephen View Post
    I did initialize i. Just to be safe, I even set it to zero just now after your post, still got the error.

    Code:
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    	
    	char  num[]= "9781552859544";
    	int i=0;
    	for (; i<12; i++)
    	{
    		
    		
    		printf("%s", num[i]);
    		
    		
    	}
    	return 0;
    }
    your modified code

    Code:
    #include <stdio.h>
    #include <string.h>
    int main()
    {
    	
    	char  num[]= "9781552859544";
    	int i=0;
    	for (; i<12; i++)
    	{
    		
    		
    		printf("%c", num[i]);
    		
    		
    	}
    	return 0;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The UNIX System Interface
    By rrc55 in forum C Programming
    Replies: 1
    Last Post: 10-20-2009, 05:56 PM
  2. Replies: 3
    Last Post: 11-17-2008, 12:36 PM
  3. code condensing
    By bcianfrocca in forum C++ Programming
    Replies: 4
    Last Post: 09-07-2005, 09:22 AM
  4. code help required
    By Yobbo in forum C Programming
    Replies: 9
    Last Post: 09-02-2005, 11:15 PM
  5. Creating 2D arrays on heap
    By sundeeptuteja in forum C++ Programming
    Replies: 6
    Last Post: 08-16-2002, 11:44 AM