473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

another weird unexplained anomaly!



Fixed font - Proportional font
string initilization WHY?
All 2 messages in topic - view as tree
puzzlecracker Jan 29, 10:47 pm show options

Newsgroups: comp.lang.c
From: "puzzlecracker" <ironsel2...@gmail.com> - Find messages by this
author
Date: 29 Jan 2005 22:47:59 -0800
Local: Sat, Jan 29 2005 10:47 pm
Subject: string initilization WHY?
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Why would this work? - and it does! any thoughts?
#include<iostream>

using namespace std;
void init(char **str){ *str="Awesome"; }
main(){

char * str;

init(&str);
cout<<str<<endl;
}

Jul 23 '05 #1
2 1155
puzzlecracker wrote:


Fixed font - Proportional font
string initilization WHY?
All 2 messages in topic - view as tree
puzzlecracker Jan 29, 10:47 pm show options

Newsgroups: comp.lang.c
From: "puzzlecracker" <ironsel2...@gmail.com> - Find messages by this
author
Date: 29 Jan 2005 22:47:59 -0800
Local: Sat, Jan 29 2005 10:47 pm
Subject: string initilization WHY?
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Why would this work? - and it does! any thoughts?
#include<iostream>

using namespace std;
void init(char **str){ *str="Awesome"; }
main(){

char * str;

init(&str);
cout<<str<<endl;
}


Well, technically it shouldn't work because main() is not a valid prototype
for main. It should be 'int main()'. But that is beside the point here.

Other than that, what is the problem? It is equivalent to

int main()
{
char* str;

str = "Awesome";
cout << str << endl;
}

Why wouldn't it work?

Ian

Jul 23 '05 #2
"puzzlecracker" <ir*********@gmail.com> writes:

Why would this work? - and it does! any thoughts?

I think it would help us reply constructively if you could explain what's so
weird, unexplained or anomalous about the pieces of code you're posting, so
that we could focus our comments accordingly. Is it the "main()" that you
find so weird? What sort of "thoughts" do you want?

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

82
by: nobody | last post by:
Howdy, Mike! mikecoxlinux@yahoo.com (Mike Cox) wrote in message news:<3d6111f1.0402271647.c20aea3@posting.google.com>... > I'm a C++ programmer, and have to use lisp because I want to use >...
1
by: Zaidan | last post by:
I am running Excel2000 under WIN98 2nd edition, and I am writing a VBA code (I will consider using javascript if I have to) that does the following, at the user command: 1- Start MS Explorer and...
6
by: geronimo_me | last post by:
Hi, I'm trying to compare two TITLE fields from different tables to locate anomolies - however Table1 TITLE field contains a dot(.) after some of the entries, however i want to remove the dot so...
188
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection -...
1
by: John | last post by:
Hi, I have an asp.net page with some validation. On one machine the button click event works fine, whilst on another the button click event does not fire at all Any suggestions welcome! Thanks...
8
by: walesboy | last post by:
greetings - I have a btnSubmit button with a Handles btnSubmit.click which works great if all the user does is click that button. But, if the user ALSO changes a text box on the page (which...
17
by: Barret Bonden | last post by:
As an old programmer just now looking at VB.net I have a question: How does one simply open one form from another ? I don't mean how does one create a new instance of that form , but rather how...
16
by: clintonG | last post by:
At design-time the application just decides to go boom claiming it can't find a dll. This occurs sporadically. Doing a simple edit in the HTML for example and then viewing the application has...
1
by: mai | last post by:
Hi everyone, i'm trying to exhibit FIFO anomaly(page replacement algorithm),, I searched over 2000 random strings but i couldnt find any anomaly,, am i I doing it right?,, Please help,,,The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.