Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. urgent :: how to break a character string into single characters?

urgent :: how to break a character string into single characters?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AnayKulkarni
    wrote on last edited by
    #1

    Hello to all, i am having a character pointer which points to a character string, lets say it is "char* A", this 'A' points to a character string lets say "Hello codeproject forum", now i want to break this string into single characters so that i can display this string character by character on a page as i am having space limitations means rather than displaying the string "Hello codeproject forum" on one line i want to display it like below- Helloco deproje ctforum how this can be done? can anybody tell me plz? its urgent. Thanks and Regards, Anay

    T 1 Reply Last reply
    0
    • A AnayKulkarni

      Hello to all, i am having a character pointer which points to a character string, lets say it is "char* A", this 'A' points to a character string lets say "Hello codeproject forum", now i want to break this string into single characters so that i can display this string character by character on a page as i am having space limitations means rather than displaying the string "Hello codeproject forum" on one line i want to display it like below- Helloco deproje ctforum how this can be done? can anybody tell me plz? its urgent. Thanks and Regards, Anay

      T Offline
      T Offline
      Tydia kun
      wrote on last edited by
      #2

      The pointer is basically a pointer to an array of chars. You can simply loop through them one by one and print 7 chars, then print a new line. char* a = some_string; int length = strlen(a); while(length > 0) { for (int i = 0; i < 7; i++) { length--; cout << *a++; } cout << endl; }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups