vector of substrings

This is a discussion on vector of substrings within the C++ Programming forums, part of the General Programming Boards category; -_- Let's stop playing....

  1. #46
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,887
    -_-
    Let's stop playing.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #47
    Banned
    Join Date
    Nov 2007
    Posts
    678
    :p ok

  3. #48
    Banned
    Join Date
    Nov 2007
    Posts
    678
    Code:
    #include <iostream>
    #include <string>
    #include <cctype>
    
    int main(int argc, char *argv[])
    {
    	if (argc != 2)
    	{
    		std::cout << "Usage\n\taa.py <number>" << std::endl;
    		return 1;
    	}
    	std::string fontMap[] = {
    		std::string("###  #  ### ### # # ### ### ### ### ### "),
    		std::string("# # ##    #   # # # #   #     # # # # # "),
    		std::string("# #  #  ###  ## ### ### ###   # ### ### "),
    		std::string("# #  #  #     #   #   # # #   # # #   # "),
    		std::string("### ### ### ###   # ### ###   # ### ### ")
    	};
    	const int FONT_WIDTH = 4;
    	const int FONT_HEIGHT = 5;
    	std::string number(argv[1]);
    	for (int row=0; row<FONT_HEIGHT; row++)
    	{
    		for (int col=0; col<number.length(); col++)
    		{
    			if (! isdigit(number[col]))
    			{
    				std::cout << "Error: Only digits allowed!" << std::endl;
    				return 1;
    			}
    			int i1 = (number[col]-'0') * FONT_WIDTH;
    			int i2 = i1 + FONT_WIDTH;
    			while (i1 < i2)
    			{
    				std::cout << fontMap[row][i1];
    				i1++;
    			}
    		}
    		std::cout << std::endl;
    	}
    	return 0;
    }

Page 4 of 4 FirstFirst 1234
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help, extracting substrings from a string
    By doubty in forum C Programming
    Replies: 1
    Last Post: 06-18-2009, 12:57 AM
  2. Need help on substrings and streams
    By TaiL in forum C++ Programming
    Replies: 2
    Last Post: 10-08-2008, 07:18 PM
  3. Searching for a series of possible substrings inside a string
    By andrew.bolster in forum C Programming
    Replies: 7
    Last Post: 02-10-2008, 02:20 AM
  4. substrings
    By arjunajay in forum C++ Programming
    Replies: 30
    Last Post: 06-10-2005, 10:13 PM
  5. Searching strings - substring's
    By Vber in forum C Programming
    Replies: 4
    Last Post: 02-06-2003, 12:05 PM

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